cancel
Showing results for 
Search instead for 
Did you mean: 

st7lite0 autoreload question

sjo
Associate II
Posted on September 20, 2004 at 06:59

st7lite0 autoreload question

7 REPLIES 7
sjo
Associate II
Posted on September 13, 2004 at 10:28

Previously instead of using the output compare mode of the autoreload timer I have used the overflow flag eg.

generate 2000Hz interrupt.

ATR = 0x10;

ATCSR = 0b00010010;

this seems to work fine if using the fcpu as the timebase, if I change to using the fltimer as the timebase the interrupt is unpredictable.

I wanted to use the overflow flag as a 1Hz interrupt, eg.

ATR = 0xC18;

ATCSR = 0b00001010;

I have solved the problem by switching back to output compare mode, is this not possible using the overflow flag?

Regards

sjo

[ This message was edited by: sjo on 13-09-2004 17:38 ]
anshul
Associate II
Posted on September 13, 2004 at 13:53

If you select your clock source as Lite Timer then your ART will be clocked by the Lite timer i.e 1msec @ 8MHz Fcpu. The 12-bit upcounter will increment every 1msec, now if you want an overflow flag at 1Hz then set the ATR value accordingly.

sjo
Associate II
Posted on September 13, 2004 at 14:55

Is 0xC18 not the correct ATR value for a 1Hz (@8MHz fcpu) interrupt then?

ATR = 0xC18;

ATCSR = 0b00001010;

Any help would be greatly appreciated.

Regards

sjo
wolfgang2399
Associate II
Posted on September 15, 2004 at 06:02

I dont think that you forget to clear the OVF flag or to save the used registers in your interrupt routine.

But there is another trap: If you read the ATCSR e.g. to check the ICF flag(Lite1X and Lite2X) the OVF will be cleared by the way.

Otherwise it would be helpfull to know a little more about your effect.

Regards WoRO
sjo
Associate II
Posted on September 15, 2004 at 09:19

Its not really problem as I can just use output compare mode.

Its just if I am using the overflow interrupt as a timebase when using fcpu as the timer clock everything behaves, as soon as I switch to using fltimer as timer clock the timings are incorrect.

eg.

2KHz interrupt (fcpu timebase)

using output compare mode

DCR0 = 0xFA0

using overflow

ATR = 0x60

the above work ok, if I change the timer clock source to fltimer, eg.

1Hz interrupt (fltimer timebase)

DCR0 = 0x3E8

using overflow

ATR = 0xC18

the output compare mode works ok but the results for overflow are very unpredictable.

I have noticed that on the flite2x datasheet it states that pwm and output compare mode should not be used with fltimer as the clock source, is this valid for flite0x aswell?

Regards

sjo
anshul
Associate II
Posted on September 17, 2004 at 13:08

With the configuration as you have suggested

ATR = 0xC18;

ATCSR = 00001010;

You should get the overflow Interrupt at 1Hz frequency.

Regarding the note you have mentioned that is only specific to Lite2. There is no such restriction for Lite0, you can use the PWM mode and the Output compare modes at FLTimer frequency
sjo
Associate II
Posted on September 20, 2004 at 06:59

I agree you should get the overflow @ 1Hz, but if you try it in silicon the results are very strange. As I had said before the results are as expected when using fcpu as the timebase.

Regards

sjo