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'IFTMR0_16bitisdefinedinthesourcecode'afunctionisthenusedforTimer0-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
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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
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
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.
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.