Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pwm-input setting for TI2 is wrong #375

Open
ceigel opened this issue Oct 27, 2021 · 4 comments
Open

pwm-input setting for TI2 is wrong #375

ceigel opened this issue Oct 27, 2021 · 4 comments

Comments

@ceigel
Copy link

ceigel commented Oct 27, 2021

I haven't checked whether this is really not working, I was just reviewing the code when I discovered this.

This is the code for setting the active polarity for capture in CCR2 the Timer::pwm_input function:

// Select the active polarity for TI1FP2 (used for capture in TIMx_CCR2): write the CC2P
// and CC2NP bits to ‘1’ (active on falling edge).
self.tim
.ccer
.modify(|_, w| w.cc2p().set_bit().cc2np().set_bit());

From documentation (chapter 18.3.6 of the Reference manual RM0090):
Select the active polarity for TI1FP2 (used for capture in TIMx_CCR2): write the CC2P bit to ‘1’ and the CC2NP bit to ’0’(active on falling edge).

I believe the code is not according to documentation, at least for STM32F405/415, STM32F407/417, STM32F427/437 and STM32F429/439 which are referenced in RM0090 from STM

@jkristell
Copy link
Contributor

I don't know if it's the intention of the code, but both set, I believe, is capture on both edges.

@ceigel
Copy link
Author

ceigel commented Oct 27, 2021

yes, that is correct, it means capture on both edges, but I still think that is incorrect. cc1np/cc1p are 00

@burrbull
Copy link
Member

burrbull commented Oct 27, 2021

Looks like original comments from RM0368/RM0383 (F401), chapter 12.3.7 or something

@ceigel
Copy link
Author

ceigel commented Oct 27, 2021

I believe you refer to this statement in RM0368:

Select the active polarity for TI1FP2 (used for capture in TIMx_CCR2): write the CC2P and CC2NP bits to ‘1’ (active on falling edge).

The equivalent statement in RM090 is this:

Select the active polarity for TI1FP2 (used for capture in TIMx_CCR2): write the CC2P bit to ‘1’ and the CC2NP bit to ’0’(active on falling edge).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants