Menu

Reading Timer0 fails

2015-12-28
2015-12-30
  • Frank Steinberg

    Frank Steinberg - 2015-12-28

    Hi!

    Yesterday I tried to read Timer0 on an AVR via the Timer0 Function, but it returns always 0. Direct reading the TCNT0 register works, so the configuration of timer0 was o.k. Today I tried the brandnew 0.95 release - all the same.

    'This Code in GCB ...
    bTim = Timer0
    '... produces this asm-output:
        lds SysValueCopy,TMR0
        sts BTIM,SysValueCopy
    

    TMR0 is a Timer-Register for PICs - this can't work.

    This issue occurs until I commented out the line
    ' #define Timer0 TMR0
    in timer.h

    'timer.h ...
    
    #ifdef PIC
    
        #ifndef TMR0_16BIT   'Test for 16Bit timer0 mode
             #define Timer0 TMR0
        #endif
        ' IF TMR0_16bit is defined in the source code
        ' a function is then used for Timer0 - WMR
    '...
    

    It seems, that a #define can't be nested in a #ifdef ... #endif. The #define is executed always, regardless if it's a PIC or not or if the TMR0_16BIT constant is defined or not. So I'm sure, a 16bit read of a PIC wouldn't work similarly.

    Regards
    Frank

     
  • Anobium

    Anobium - 2015-12-29

    Yes. That is not correct. Thamk you for a clear and consise posting. Really helps.

    It will take a short while to fix. We can post a fix shortly.

     
  • Anobium

    Anobium - 2015-12-30

    There was an error. We have updated timer.h, download here

    You only need to download this file in the build v.95.001. v.95.002 contains this file.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.