Timer bit definitions

Post Reply
J. Brokking
Posts: 2
Joined: Sat Sep 30, 2017 9:06 pm

Timer bit definitions

Post by J. Brokking » Sat Sep 30, 2017 9:25 pm

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?

User avatar
RogerClark
Posts: 7494
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Timer bit definitions

Post by RogerClark » Sat Sep 30, 2017 10:08 pm

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.

stevestrong
Posts: 1838
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: Timer bit definitions

Post by stevestrong » Sun Oct 01, 2017 7:00 am

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.

J. Brokking
Posts: 2
Joined: Sat Sep 30, 2017 9:06 pm

Re: Timer bit definitions

Post by J. Brokking » Mon Oct 02, 2017 7:54 pm

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.

Post Reply