Skip to main content
Visitor II
April 24, 2007
Question

How to read a timer's value

  • April 24, 2007
  • 5 replies
  • 892 views
Posted on April 24, 2007 at 10:01

How to read a timer's value

    This topic has been closed for replies.

    5 replies

    lseletronAuthor
    Visitor II
    April 23, 2007
    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,

    Visitor II
    April 24, 2007
    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)

    Visitor II
    April 24, 2007
    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

    Visitor II
    April 24, 2007
    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

    lseletronAuthor
    Visitor II
    April 24, 2007
    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.