KansaiRobot
Member
Hello and thanks always.
I am working maintaining a code for a STM8, that involves timers. The clock is set at 16MHz, ergo 0.0625uS. The settings of the timer are ARRH=0x03 and ARRL=0x20 therefore(0x0320=800) it resets at 800( 50uS). PSCR is set to 0 so the timer has the same freq as the micro
Anyway, I checked with an oscilloscope and it does not give good readings. The timer interrupt is called at
56us , 54uS, 54uS, 52uS, 52uS, 52us, 38us(!!!), 42us(?), 50us, 50us....
curiously summed up it gives 500uS so it does count as 10 times 50uS
The first 8 times at the timer interrupt some AD conversion is happening so I think that the AD finished interrupt is being called in between too.
I disable the AD conversions and the timer interrupt is called at exactly 50uS, so I am concluding that the AD conversion is what is affecting the timing of the timer. Any comments on this??
1) How would you use the AD conversion on a regular time basis?
but what is puzzling me is :
2) why does it "correct" itself by firing an interrupt at 38uS?? (and later 42uS)
I would appreciate any comment based on your embedded or STM8 experience, has something of this sort ever happened to you?
I am working maintaining a code for a STM8, that involves timers. The clock is set at 16MHz, ergo 0.0625uS. The settings of the timer are ARRH=0x03 and ARRL=0x20 therefore(0x0320=800) it resets at 800( 50uS). PSCR is set to 0 so the timer has the same freq as the micro
Anyway, I checked with an oscilloscope and it does not give good readings. The timer interrupt is called at
56us , 54uS, 54uS, 52uS, 52uS, 52us, 38us(!!!), 42us(?), 50us, 50us....
curiously summed up it gives 500uS so it does count as 10 times 50uS
The first 8 times at the timer interrupt some AD conversion is happening so I think that the AD finished interrupt is being called in between too.
I disable the AD conversions and the timer interrupt is called at exactly 50uS, so I am concluding that the AD conversion is what is affecting the timing of the timer. Any comments on this??
1) How would you use the AD conversion on a regular time basis?
but what is puzzling me is :
2) why does it "correct" itself by firing an interrupt at 38uS?? (and later 42uS)
I would appreciate any comment based on your embedded or STM8 experience, has something of this sort ever happened to you?