cancel
Showing results for 
Search instead for 
Did you mean: 

STM8L DISCOVERY - How much time is required for forced event generation?

kim_boma
Associate

I tried to initialize the prescaler value and the counter of the TIM1 peripheral by forced update generation, but I failed to implement it with the following code (including 'stm8l152c6.inc' file from 'st_toolset\asm\include'):

 

 

 

 

 

 

 

 

mov TIM1_CR1,#$10  ; Use the counter as down-counter.
mov TIM1_PSCRH,#$01
mov TIM1_PSCRL,#$F3
mov TIM1_ARRH,#$0F
mov TIM1_ARRL,#$9F
mov TIM1_EGR,#$01  ; Generate an update.
mov TIM1_SR1,#$FE  ; Clear an update interrupt flag.
mov TIM1_IER,#$01  ; Enable update interrupts.

 

 

 

 

 

 

 

 

I used update interrupts for LED blink and an unintended blink occured when I start the application. I guessed that an update generation is not done when the line "mov TIM1_SR1,#$FE" is executed to clear an update interrupt flag.

I added just a line into the code above.

 

 

 

 

 

 

 

 

mov TIM1_CR1,#$10
mov TIM1_PSCRH,#$01
mov TIM1_PSCRL,#$F3
mov TIM1_ARRH,#$0F
mov TIM1_ARRL,#$9F
mov TIM1_EGR,#$01
nop
mov TIM1_SR1,#$FE
mov TIM1_IER,#$01​

 

 

 

 

 

 

 

 

The nop instruction delays the operation and it works. LEDs do not blink at the start in the modified application.

I want to know that how much time is required for forced event generation as described in the title. The RM0031 manual and the product specifications of STM8L152C6 does not provide useful information for that.

0 REPLIES 0