Timer3 runs 2x faster than expected
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-04 8:07 AM
Posted on August 04, 2016 at 17:07
Timer3 runs 2x faster than expected
I know what many readers are thinking but read onI set my STM32F746 (DISCOVERY PCB) for SysClk=216 MHzAHB Prescaler set to �1 thus HCLK = 216 MHzAPB1 prescaler set to �4 thus PCLK1 = 54 MHz & APB1 timer clocks are 108 MHzAPB2 prescaler set to �2 thus PCLK2 = 108 MHz & APB2 timer clocks are 216 MHz (RCC_CFGR: PPRE2=4 and PPRE1=5 -- I checked)Timer3 is on APB1 thus its input clocking is 108 MHzUnless my understanding is bad, its CK_PSC is also 108 MHzThen setting TIM3_PSC to 1 (�2) CK_CNT = 54 MHzThen setting the auto reload register (TIM3_ARR) to 54000 should set the UIF bit in TIM2_SR at 1 KHz.I use Timer3 / ISR to make a 1 kHz up-counter in RAM.But the damn thing up-counts at 2 kHz. Setting TIM3_PSC to 3 (�4) gives me my desired interrupt rate. Thus I have a workaround.As a sanity check I used the ARM 24-bit timer running at HCLK (no �8) with 0xFFFFFF reload also performing a RAM increment. I did this running a while(1) which, because I prefer assembly, was written as �b .�In 60 seconds (eyeball on a sweep second hand) I got 744 ARM timer counts while I got 120338 �millisecond� interrupts. The count of 744 ARM timer interrupts is well within error limits for pressing pause on the debugger. FWIW, caching is disabled by reset and any existing cache has been scrubbed.Clearly I misunderstood something. But what? #!timer #stm32f746-discovery
Labels:
- Labels:
-
STM32F7 Series
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-04 8:24 AM
Posted on August 04, 2016 at 17:24
[DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Discovery/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Discovery/Timer3%20runs%202x%20faster%20than%20expected&FolderCTID=0x01200200770978C69A1141439FE559EB459D75800084C20D8867EAD444A5987D47BE638E0F&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Discovery/AllItems.aspx¤tviews=1]Cross-Posted
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
