cancel
Showing results for 
Search instead for 
Did you mean: 

ART timer trouble on ST72F62

bansidhe77
Associate
Posted on April 27, 2004 at 07:59

ART timer trouble on ST72F62

1 REPLY 1
bansidhe77
Associate
Posted on April 27, 2004 at 07:59

Hi everybody,

I have been having some trouble with the ART timer on an ST72F621L4 chip.

I start the timer off in an SPI interrupt, and then stop it again in the ART interrupt routine. I have set the ARTARR to 251 and the prescaler to divide by 128, and I'm running at 4MHZ fcpu.

Most of the time this works perfectly and gives an ART interrupt about 128us after the timer is started. But sometimes there is a problem and the timer takes just over 8ms to trigger an interrupt. This 8ms period looks very much like the ARTCAR has been loaded with 0 or 1 rather than being loaded with 251 as I have specified in the ARTARR. It has been confirmed that the ARTCAR has been set to a value less than 251, and ARTARR still contains 251.

Can anyone think of a reason why this might happen?

A few bits of info to help you along the way are:

- occurrence of this problem is infrequent. The timer is started every 400us or so, and it only fails once every few minutes on average. After the error, it continues on OK for another few minutes.

- There is a current workaround to the problem, which involves checking to see if the ARTCAR is less than 251 at main level, and setting it to 251. Writing to ARTCAR in this way does not work straight away when the bug occurs, as several writes are required for ARTCAR to take on the desired value (is it stuck at 0?)

The code snippet of what is done at startup looks like this:

// ART / PWM timer init

ARTCSR = 0x72; // OIE and prescaler 128

ARTARR = 251;

PWMCR = 0;

PWMDCR0 = 0;

PWMDCR1 = 0;

ARTICCSR = 0;

The timer is started within an SPI interrupt with the following code:

ARTCSR |= 0x04; // FCRL

ARTCSR |= 0x08; // TCE

The timer is stopped at the start of the ART interrupt with this code:

ARTCSR &= ~0x08; // ~TCE

ARTCSR |= 0x04; // FCRL

Does anyone know of a reason why ARTCAR might take on the wrong value like this?

Thanks for any help,

Marcus.