cancel
Showing results for 
Search instead for 
Did you mean: 

ST7FLITE29 Auto Reload Timer

fggnrc
Associate II
Posted on March 10, 2005 at 05:18

ST7FLITE29 Auto Reload Timer

3 REPLIES 3
fggnrc
Associate II
Posted on March 08, 2005 at 10:14

Hello!

I need to read the value of the 12bit Auto Reload Timer which is fed by fosc (8 Mhz).

The ST7FLITE2x documentation says that I should read CNTRL, then CNTRH.

I wonder if this is correct.

My doubts arise from this reasoning: suppose that the code reads CNTRL and that 0xFF is its value.

When it will read CNTRH, at least 3 clock cycles may have been elapsed, so the code WILL NOT read the counter value when the first access occours with an error of 256 / fosc.

If the most significant bits are latched when CNTRL is read, my reasoning is obviously wrong...

Any hints?

EtaPhi

Post Scriptum:

Is there a way to force an input capture event by software ?

If my reasoning is true, this could be a workaround...

The other one, could be to do what the documentation discourages: read first CNTRH, then CNTRL and subract 3 clock pulses to the latter value.

wolfgang2399
Associate II
Posted on March 10, 2005 at 05:03

Hi EtaPhi,

very interesting what you found out!!!!!! Because the recommended order is exactly in opposite to the way all the ST72xxx-µCs need their 16-bit timers:

16-bit Read Sequence: (from either the Counter

 

Register or the Alternate Counter Register)...

 

The user must read the MS Byte first, then the LS

 

Byte value is buffered automatically.

 

This buffered value remains unchanged until the

 

16-bit read sequence is completed, even if the

 

user reads the MS Byte several times.

Additionally there is a mighty step back in the methods reading the input capture and writing to the output compare registers. The unsafe way how it is done in the ST7Litexx may cause spurious results.

I'm looking forward to a statement of an expert of STM.

Regards WoRo

fggnrc
Associate II
Posted on March 10, 2005 at 05:18

The read of the Auto Reload Counter value is no more an issue for my application since I changed the frequency of PWM outputs.

Instead of using ATRH=0x00 and ATRL=0x00 to obtain maximum resolution, now I use ATRH=0x0F anf ATRL=0x00.

In this new set-up, the CNTRH is always 0x0F.

This semplifies also the code and reduces its footprint :-).

BTW, the new ST7 library does not provide access to the counter value...

Regards,

EtaPhi