I am using MPLAB X IDE version 5.43 to develop an embedded project for a PIC18F8722 microcontroller.
It has a timer TMR0 which can be configured to be 32 bits.
I had lots of statements:
TMR0L = 0;
TMR0H = 0;
that I wanted to simplify (i.e., replace) to:
TMR0 = 0;
The 3 identifiers above are defined through macro constants in the included file #include <pic18f8722.h> as shown in this snippet:
// Register: TMR0
#define TMR0 TMR0
extern volatile unsigned short TMR0 __at(0xFD6);
#ifndef _LIB_BUILD
asm("TMR0 equ 0FD6h");
#endif
// Register: TMR0L
#define TMR0L TMR0L
extern volatile unsigned char TMR0L __at(0xFD6);
#ifndef _LIB_BUILD
asm("TMR0L equ 0FD6h");
#endif
// Register: TMR0H
#define TMR0H TMR0H
extern volatile unsigned char TMR0H __at(0xFD7);
#ifndef _LIB_BUILD
asm("TMR0H equ 0FD7h");
#endif
However, the above substitution in my code (TMR0L=0 and TMR0H=0 with TMR0=0) surprisingly DOES NOT work, i.e., the functions using TMR0 stop doing their job and give errors.
Did anybody ever notice such bizarre, strange behavior and, above all, could explain WHY it is happening?
TMR0 = 500) into the appropriate assembly code to load the value in 8-bit chunks (i.e.movlw 0xF4 movwf TMR0L movlw 1 movwf TMR0H). This issue might be specific to your application. That's why an additional context would be helpful to catch this bug. By the way, you use XC8 compiler, don't you? You see, we have to guess everything :D.