cancel
Showing results for 
Search instead for 
Did you mean: 

Timer 2 on STM32F401C Discovery Board

psdeering
Associate II
Posted on September 10, 2015 at 15:28

Hi all,

I've just started playing with the STM32F4 on the STM32F401C Discovery board, and had some strange behaviour (slowed down time) when attempting to generate a 1ms TIM2 interrupt.

From the reference manual for the microcontroller, I have enabled HSE via SW in RCC_CR to give me a (supposedly) 8Mhz reference clock (external 8Mhz crystal) to drive the AHB bus.  Both AHB and APB1 prescalers are set at 0, so no clock division on the bus clocks.

From this, I assume that the clock driving the prescaler for TIM2 should be 8Mhz.  I have set the prescale for TIM2 at 7 (CK_CNT = CK_PSC / 8), which, presumably, should give me a 1Mhz clock driving the counter (CK_CNT = 1Mhz).  I have set ARR at 999, which I assumed would supply a 1ms interrupt.  This clearly isn't the case.

Am I misreading the the documentation?  Have I missed something?

Thanks,

Paul
2 REPLIES 2
psdeering
Associate II
Posted on September 10, 2015 at 15:30

Also, this is on the bare hardware without the HAL or standard libraries.

 

 

Thanks,

 

Paul

 

 

Posted on September 10, 2015 at 18:35

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Timer%202%20on%20STM32F401C%20Discovery%20Board&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx&currentviews=3]Do we have to cross-post this to all three forums here? The pool's pretty shallow

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..