I am having a strange issue with calculating the timer value of a PIC18F27J13. This chip has the capability of setting the timer with one 16 bit write. Which I have enabled.
T3CONbits.RD16 = 1; // Enables register read/write of Timer3 in one 16-bit operation
This is not working correctly. The timer is actaully interrupting as if I set it to 0XFFFF.
unsigned delayTime;
Sample 1
delayTime = 287;
TMR3 = (0xFFFF - delayTime);
Sample 2
delayTime = (0xFFFF - 287;
TMR3 = delayTime ;
If you do the math the value in TMR3 should be FEE0 but when I look at it with the debugger I am getting FFE0. It seems like the high byte is not being set.
But this works as expected.
TMR3 = (0xFFFF - 287);
After looking at TMR3 here it works fine as expected. I get 0XFEE0 in the TMR3 register.
In all cases, delayTime contained the expected value.
I am probably going to back to the old fashioned 2 8 bit operations but I am curious as to why this is not working. Has anyone had experience withe the RD16 feature? Why would the first two bits of code not work but the third does?
T3CONbits.RD16 = 1; // Enables register read/write of Timer3 in one 16-bit operation
This is not working correctly. The timer is actaully interrupting as if I set it to 0XFFFF.
unsigned delayTime;
Sample 1
delayTime = 287;
TMR3 = (0xFFFF - delayTime);
Sample 2
delayTime = (0xFFFF - 287;
TMR3 = delayTime ;
If you do the math the value in TMR3 should be FEE0 but when I look at it with the debugger I am getting FFE0. It seems like the high byte is not being set.
But this works as expected.
TMR3 = (0xFFFF - 287);
After looking at TMR3 here it works fine as expected. I get 0XFEE0 in the TMR3 register.
In all cases, delayTime contained the expected value.
I am probably going to back to the old fashioned 2 8 bit operations but I am curious as to why this is not working. Has anyone had experience withe the RD16 feature? Why would the first two bits of code not work but the third does?