cancel
Showing results for 
Search instead for 
Did you mean: 

How to read a timer's value

lseletron
Associate II
Posted on April 24, 2007 at 10:01

How to read a timer's value

5 REPLIES 5
lseletron
Associate II
Posted on April 24, 2007 at 00:11

Hi,

The datasheet for 72325 states that:

QUOTE

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.

END QUOTE

Does that mean that if I write code like this:

unsigned int TimerValue;

...

TimerValue=TACR;

the compiler will automatically do as quoted from the datasheet?

I did have a look at the assembly but could not make out much

Thanks,

luca239955_st
Associate III
Posted on April 24, 2007 at 06:08

yes, the compiler will generate a code that reads the MSB first, as required by the datasheet.

Regards,

Luca (Cosmic)

wolfgang2399
Associate II
Posted on April 24, 2007 at 09:13

... when you use the COSMIC compiler, everything is o.k.

But:

As it is not prescribed (in ANSI-C), other compilers may apply the reverse sequence to read or write a 16-bit integer.

Regards

WoRo

wolfgang2399
Associate II
Posted on April 24, 2007 at 09:41

... when you use the COSMIC compiler, everything is o.k.

But:

As it is not prescribed (in ANSI-C), other compilers may apply the reverse sequence to read or write a 16-bit integer.

Regards

WoRo

lseletron
Associate II
Posted on April 24, 2007 at 10:01

Hi,

Thank you for your replies.

I guess in cases like this the chip's nature must take priority over ANSI C. The registers in question are not just simple ROM/RAM locations but rather special ones and their hardware implementation apparently has impact on the way these registers are read/written.