cancel
Showing results for 
Search instead for 
Did you mean: 

simulator artimer problem

sjo
Associate II
Posted on November 07, 2006 at 07:59

simulator artimer problem

4 REPLIES 4
sjo
Associate II
Posted on October 29, 2006 at 11:33

I am targetting the ST7FLIT15BF0 in the simulator (Visual Develop v3.3.2 patch 2). The code is taken from a working application but fails to simulate.

This is the setup:

#define TIMRELOAD 1000

PWMCR = 0;

ATCSR = 0b00001001;

DCR0 = CNTR1;

if(!(DCR0 += TIMRELOAD))

DCR0L = 1;

ATCSR;

PWM0CSR;

and the interrupt routine is as follows:

@interrupt void tbase(void)

{

// reload timer

if(!(DCR0 += TIMRELOAD))

DCR0L = 1;

PWM0CSR; // clear CMPF0 flag

}

This should give me a 1 sec int @ 8MHz fcpu.

If i simulate using the flite0x family it works, but if i simulate with 1x, 2x, 1xb, 3x the code only hits the interrupt after a timer overflow.

Is this behaviour known, or am i doing something wrong ?

Regards

sjo

robertjamier9
Associate II
Posted on November 06, 2006 at 08:38

The flite0x ART is special.

It only works for the flite0x because the DCR0H and DCR0L registers are loaded immediately without waiting for an overflow event.

If you want to reproduce the same behaviour on a flite2x for example, you have to reset the TRAN bit in the TRANCR register.

Best regards,

Robert

sjo
Associate II
Posted on November 06, 2006 at 09:49

Hi,

Yes sorry, the trans bit is being set in the 1x version, i sent the flite0x code by mistake.

But is still does not work, the interrupt is after about 3secs, not 1 as expected.

I am now using a flite39 to develop code, this also behaves the same.

It look like the simulator is behaving as per silicon, just cannot figure out if i am doing anything wrong.

Any ideas ?

Regards

sjo

sjo
Associate II
Posted on November 07, 2006 at 07:59

I have looked into this further, it looks like the addition of the TRAN bit has help with the pwm function but not the output compare when using FLTimer as the timebase.

Info: fcpu 8Mhz, compare interrupt, timebase FLTimer, reload value 1000

so we write the new DCR0 value and set the TRAN bit, the problem is we have to wait for a overflow before this is copied to the active DCR0 register.

When you are using the FLTimer as the timebase this can take upto 4095 @ 1ms tick = 4 secs to reload the value !!

I could use the overflow interrupt but again i have to wait for the counter to reach the ATR value - this can take 3 seconds for my 1sec tick.

Some feedback from ST would be nice, are there any ways to implement a 1 second tick on the newer ARTimers ?

Cheers

sjo