On Tue, Sep 17, 2013 at 9:09 PM, Andrew McLaren <and...@aratika.co.nz> wrote:
> The logic maintains a reference timebase using the timer B module (this
> simply ticks away in the background and maintains a reference counter). To
> obtain a time reference at any time, the logic stops the timer block, reads
> the TBR, and restarts the timer block. Nothing really fancy there.

Why are you stopping the timer? I understand that the timer updates
asynchronously, so the value may not be stable, but you can get around
that by taking multiple readings until you see two that are the same:

unsigned read_timer(void)
{
    unsigned base, sample;
    sample = TB0R;
    do {
        base = sample;
        sample = TB0R;
    } while (base != sample);
    return sample;
}

Given the device erratum, this approach would probably make more
sense. It works as long as the clock is somewhat slower than your CPU
clock (like 16x slower).

-William

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/20/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=58041151&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to