Page 1 of 1

Timer bit definitions

Posted: Sat Sep 30, 2017 9:25 pm
by J. Brokking
In the file: Arduino_STM32-master\STM32F1\system\libmaple\include\libmaple\timer.h the individual bits for the timer registers are defined:

#define TIMER_CCMR1_CC2S_INPUT_TI1 (TIMER_CCMR_CCS_INPUT_TI1 << 8)
#define TIMER_CCMR1_CC2S_INPUT_TI2 (TIMER_CCMR_CCS_INPUT_TI2 << 8)

#define TIMER_CCMR1_CC1S_INPUT_TI1 TIMER_CCMR_CCS_INPUT_TI1
#define TIMER_CCMR1_CC1S_INPUT_TI2 TIMER_CCMR_CCS_INPUT_TI2

In the datasheet the following can be found in the register description (CCMR1):
CC2S[1:0] 01: CC2 channel is configured as input, IC2 is mapped on TI2
CC1S[1:0] 01: CC1 channel is configured as input, IC1 is mapped on TI1

In my humble opinion the definitions in the timer.h are incorrect. TI1 and TI2 should be swapped for CC2S. Same goes for the CCMR2 register. Will this be changed in the future?

Re: Timer bit definitions

Posted: Sat Sep 30, 2017 10:08 pm
by RogerClark
From time to time we come across places where things are not defined correctly in the original codebase produced by LeafLabs in 2012

Please submit a PR with the changes you think are necessary, and the community will review it and include if approved.

Re: Timer bit definitions

Posted: Sun Oct 01, 2017 7:00 am
by stevestrong
Yea, this is also part of the one of my PRs, hidden whitin the ILI9341 development.
https://github.com/rogerclarkmelbourne/ ... e5ffbe749e
I detected this issue during the OV7670 camera related projects where I use input capture to trigger DMA to read GPIO input values.

Re: Timer bit definitions

Posted: Mon Oct 02, 2017 7:54 pm
by J. Brokking
Thank you for your reactions. As it is already part of stevestrong's PR's I will not add another one for the same issue.