2018-01-13 08:34 AM
Hello,
I would like to ask about difference between update and overflow interrupt on STM8.
For Example, on Timer2:
//F_CPU 1Mhz
//Timer2 - 16bit, max value = 65535
TIM2_TimeBaseInit(TIM2_PRESCALER_1, 999);
As I understand:
1. Overflow interrupt will occur after counting to max value of timer = 65536
2. Update interrupt will occur after counting to value 999
Is it right?
2018-01-13 09:37 AM
Nope, it isn't.
STM Timers don't have an overflow at MAX. They are auto-reload counters, and they overflow at ARR always.
In your case 999. (You probably want an 1000 interval?)
Anyway, in STM terminology, an 'update' includes an 'overflow', the 'update' is more generic, but can be an overflow, among other 'update events'.
Long story short, overflow is always an update, and in case you only want overflow, they are just the same thing.
So in your specific case, you will get an interrupt at 999 and the counter will restart automatically from zero. It will not reach 65535.
You must read more carefully the timers section of the manual. STM timers are a bit different from others, but the good thing is that they are quite the same in STM8 and STM32 families.