cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up TIM2 with ISR

neyugncul
Associate
Posted on January 14, 2014 at 00:52

I am new to ARM and have been figuring out ways to set interrupts for certain peripherals that I have hooked to my board; however, I am having trouble understanding how to set up the vector interrupt table so it knows where to look for my ISR.

At the moment, I have configured Systick and I am using that for a delay function which works perfectly fine. My interrupt vector table looks like the following:

My interrupt vector table looks like the following:
; --- Vector table definition
.section ''.cs3.interrupt_vector''
.long __cs3_stack /* Top of Stack */
.long Reset_Handler 
.long NMI_Handler 
.long HardFault_Handler 
.long MemManage_Handler 
.long BusFault_Handler 
.long UsageFault_Handler 
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long 0 /* Reserved */
.long SVC_Handler 
.long DebugMon_Handler 
.long 0 /* Reserved */
.long PendSV_Handler 
.long SysTick_Handler
.long
...... all the way to
.long TIM2_Handler /* TIM2_Handler */ 

I am trying to figure how to set TIM2 to create an interrupt which is then handled every 60Hz. I've written the TIM2 initialization in assembly, but after reading the reference manual several times I am only sure of a few registers to set (CR1,CR2,DIER,CNT,PSC,ARR)... Okay, excuse my rambling, but I am trying to ask: 1) How do I set it so TIM2_Handler is called every 60 Hz? 2) How does it know to call TIM2_Handler from the vector table when TIM2 sets an interrupt flag?
2 REPLIES 2
Posted on January 14, 2014 at 01:40

It might help to specify the chip, and the frequency it is running at.

The interrupt/peripheral association is hard wired via the NVIC, you will need to configure/enable the NVIC.

If you have a 72 MHz clock

72000000 / 60 = 1200000

12000 * 100 = 1200000 (Factoring)

Set the Prescaler to 100 - 1 (PSC)

Set the Period to 12000 - 1 (ARR)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
neyugncul
Associate
Posted on January 14, 2014 at 03:38

Got it to work, thank you for the advice!