cancel
Showing results for 
Search instead for 
Did you mean: 

I must reload IMMEDIATELY LTCSR2: can I?

ciccio2
Associate II
Posted on January 27, 2005 at 06:01

I must reload IMMEDIATELY LTCSR2: can I?

3 REPLIES 3
ciccio2
Associate II
Posted on January 13, 2005 at 05:30

I must reload the timer LTARR of LTCSR2.

If i reload LTARR with new value, the new value is will reload at next overflow not immediately.

I have tried:

RIM; // disable interrupt

LTARR = 0xD3; // reload count

SIM; // enable interrupt

but don't run.

Also:

LTCSR2 = 0x00; // disable int TimeBase 2

LTARR = 0xD3; // reload count

LTCSR2 = 0x20; // enable int Time Base 2

help....thanks

fggnrc
Associate II
Posted on January 15, 2005 at 03:42

Hello Marchino!

If your timer works like the ST7FLITE29 timebase counter 2, there is no way of immediately reset the counter.

The Lite Timer Counter 2 (LTCNTR) register is read-only and its value is going to be updated by the Lite Timer Auto-Reload Register (LTARR) one at the next overflow.

These limitations are sound: if you would immediately reset the counter, the first update were too earlier, the error were the same of the current arrangement and there might be propagation time problems in the hardware (think what may happen when you reset the counter 50 ns before the next tick).

You have to use the auto-reload timer in a prediction style: at the next counter overflow you have to be sure that the LTARR will contain the right value. All you have to do is update the value of LTARR according to your needs.

To minimize the syncronization error (the one given by the absence of a way to immediately reset the counter), put $FF in LTARR during the initialization routine. In this way the syncronization error would be less than 4 us (i.e. one tick @ 8MHz).

My project uses the Lite Timer Counter 2 and its auto-reload feature to implement an half-duplex software SCI.

I have attached its source as an example of this concept.

Please, be informed that this code is not yet tested and that it implements a fixed 9600 baud rate (i.e. 104 us bit rate), one start bit, eight data bits, a parity bit and a stop bit.

It uses the pin PB5 to activate the receiver or the driver of a RS-485 transceiver and pin PB6 to exchange data with it.

The interrupt handler routine RXTX_TIMER_INT deals with the communication stuff and it is optimized for speed AND NOT FOR SPACE.

RXTX_TIMER_INT is an example of a prediction-style programming.

I hope it would be useful...

Best regards,

EtaPhi

Post Scriptum

Come on, sales engineers at STM...

Now you have some material to write an application note:

- an example of use of Lite Timer Auto-Reload Register;

- a fast dispatch by an indirect addressing jump

- another way to implement a software UART (see also AN1753)

If you don't understand my italian remarks, let me know...

________________

Attachments :

RXTX.asm : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I09w&d=%2Fa%2F0X0000000bVw%2FXc2cfRKA_RibCiXRedk.ZSWiJjlwFeSJu4Ph_2htj6U&asPdf=false

RXTX.inc : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0Bc&d=%2Fa%2F0X0000000bVt%2FLQkFovPLQf0x2DUOT8yhZJJSPKmyGH3BA39WlZorKgE&asPdf=false
ciccio2
Associate II
Posted on January 27, 2005 at 06:01

Goog idea ''put $FF in LTARR'' :)

Thanks a lot!! :-]