About the timer capture register.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-07-31 3:30 AM
If you read the capture register like this
uint16_t capch;
capch=*((uint16_t*)&TIM2_CCR3H);
This code will be compiled into an ldw instruction.The data is read incorrectly.
The following code gives the correct result.
uint16_t capch;
((uint8_t *)&capch)[0]=TIM2_CCR3H;
((uint8_t *)&capch)[1]=TIM2_CCR3L;
This means that the CCR has a shadow buffer register.
Could you tell me please, in what document about this said, thank you
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2019-07-31 4:31 AM
CCR is constant until some capture happens. So a correct result is expected as long as no capture happens between the two reads. Try with the CNT register with no prescaler. Then you can see if some shadow buffer is involved.
