cancel
Showing results for 
Search instead for 
Did you mean: 

timer overflow interrupt

pedropbr
Associate II
Posted on November 13, 2010 at 00:51

timer overflow interrupt

12 REPLIES 12
Posted on May 17, 2011 at 14:14

I need to use timer overflow interruption to blink a LED in STM32F107C.

 

I am using IAR IDE for programming.

 

Can somebody help me?

 

Try looking at the STM32 example code, pretty sure both IAR and Keil come with plenty of example code if you care to look it over.

Examples\ST\STM32F10xFWLib\Examples\TIM\TimeBase

SysTick example might also be instructive.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pedropbr
Associate II
Posted on May 17, 2011 at 14:14

Hi,

What's the best way to debug? I mean, I'd like to know if the timer is running.

Thanks
Posted on May 17, 2011 at 14:14

What's the best way to debug? I mean, I'd like to know if the timer is running.

This will depend a lot on the equipment you have. I'd have the timer output on a pin, and check it on an oscilloscope, but I'm more interested in fine granularity timing. For 1/4 Hz or slower toggling an LED works fine for visual inspection.

You could also snap shot the CPU instruction cycle counter at the interrupt, and print it out to the serial port in a foreground task. This would provide a fine grain measurement of period and interrupt latency.

You could count the observed interrupt, print that out once a second.

You should be able to breakpoint the timer interrupt handler with a USB JTAG pod (J-Link for IAR), you can in Keil, but at least one forum member has claimed this is not possible in IAR. Kind of doubt that, but whatever. Break points will however mess with the periodicity.

The STM32VL Discovery board includes a STM32F100 and an ST-LINK JTAG debugger. It has a couple of LEDs, and easy access to the GPIO pins. Costs ~$10 + shipping. They are good for checking/validating code and ideas outside of a more complex board/project environment. They don't have an RS232 serial connection, which makes the a little less than ideal, but a lot better than some STM32 stamp boards without a proper JTAG connection.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
nanayakkaraan
Associate II
Posted on May 17, 2011 at 14:14

Hello Peter,

I do not know how my reply will help you.

The things which I needed to make the interrupts work I have mention some where else in the blog. Any way these are the things I needed to done

  • I used header file stm32l1xx.h
  • stm32l1xx_it.h and stm32l1xx_it.c are the ineterrupt files needed to be added to your project.Your own interrupts can be  declared accordingly.
  • After configuring port registers and relevant registers you need to enable interrupt in your main program.
Thanks

pedropbr
Associate II
Posted on May 17, 2011 at 14:14

Hi again,

Thanks for the answers. Now I have to configure the timer to start on the rising edge os the GPS 1PPS.

Which of the following modes of timer do I have to configure:

1) Input capture mode

2) External trigger sync

3) Another?

Thanks

Posted on May 17, 2011 at 14:14

Timers and external trigger synchronization

Slave mode: Reset mode

Slave mode: Trigger mode

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pedropbr
Associate II
Posted on May 17, 2011 at 14:14

Both? Do I have to configure anything else? GPIO? NVIC?

I  tried unsuccessfully, the entire day, to config PC7/TIM3 (I have no restrictions about Ports/Timers) to detect the GPS' 1PPS rising border. Does anyone, please, has an example of using this?

I'm using the examples located in C:\Program Files\IAR Systems\Embedded Workbench 5.4 Kickstart\arm\examples\ST\STM32F10x\stm32f10x_stdperiph_lib\Project\STM32F10x_StdPeriph_Examples.

I used The ''InputCapture'' example and modified to GPIOC.

Maybe should I use the ''ExtTrigger_Synchro''?

Thank you very much!

Posted on May 17, 2011 at 14:14

I would say the Reset Mode, if I wanted to start the timer ticking at the 1PPS. There will be a slight latency, but it's only a 16-bit counter so you're not going to get fantastic granularity if it ticks over a second period with out wrapping. Assuming here you're trying to count off milliseconds, or 100's of microseconds.

Are you looking to mark time from the top-of-second, or count the 1PPS pulses? Or measure the pulse width.

Input Capture is going to count pulses.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pedropbr
Associate II
Posted on May 17, 2011 at 14:14

I have to measure how many clocks (periods) I have during 1s.

The nominal clock is 25Mhz.

I have to measure it using the GPS 1PPS as reference to check the real clock.

Thanks again!