PIC Microcontroller TIMER TMR1L AND TMR1H

Status
Not open for further replies.

arbabar

Member level 2
Joined
Aug 11, 2011
Messages
46
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,288
Location
Islamabad
Activity points
1,640
what values will be in hexadecimal if we assign TMR1H and TMR1L as


TMR1H=-5000; // Hex equivalent is FFFFFFFFFFFFEC78 but TMR1H is only 8bit so which one of the hex value the controller assume?isnt
TMR1L=-5000>>8 it overflow because of huge FFFFFFFFFFFFEC78.
 

The HEX equivalent of -5000 is 0xEC78 for a 16-bit representation.

TMR1H = 0xEC and TMR1L = 0x78

Is this to what you are referring?


BigDog
 
TMR1H=-5000; // Hex equivalent is FFFFFFFFFFFFEC78
Correct, but for a 128bit (16x8bit) number, I see the linkage..

I've just checked Hit-Tech C and it is possible to do just "
Code:
TMR1=(unsigned int)-5000;

Using MPLAB sim I did
Code:
TMR1L=(unsigned int) -5000;
and the result was 0x78, the last 8 bits... Interesting and informative, thanks Arbabar and of course BD mate...

Cool,
NEAL
 
I am sorry, on review that'd be a 64bit number!!! When there are too many digits things get confusing at any level!

16 x digits would be 16 x 4bits, or 8x8...

Cool, I always check the morning after I write anything, for this reason, no stress mate
Have fun
NEAL
 

The HEX equivalent of -5000 is 0xEC78 for a 16-bit representation.

TMR1H = 0xEC and TMR1L = 0x78

Is this to what you are referring?


BigDog

first of all Congratulations NATO routes Reopen. USA help Pakistan lot in war against terrorism.
Ur an american i think so that why i am saying to u its benefit for both of us.

now coming towards my confusing

1-yeah but TMR1H & TMR1L are 8-8 bit register respectively if we set the T1CON 16-bit timer.
now if we set TMR1H=-5000 which is equivalent to 0xEC78 then how the compiler know which eight bits should be taken first two or last two.
in datasheet example if found that the santax is only eight bits for each (TMR1H and TMR1L).


2- the second thing is TMR1H=-5000>>8
if compiler understand automatically that 0xEC78, EC is Higher 8bits and 78 are lower 8bits then why we are using right sift operator >>.


THANKX

- - - Updated - - -



NO, i think -5000 //hex equivalent is FFFFFFFFFFFFEC78 which is 16x4=64bits.
but as TMR1H=8bits so EC = 4x2=8bits and 78=4x2=8bits too hence total is 16bit because we have 16bit timer.
but confusion is that how compiler know if we feed TMR1H=-5000 which is TMR1H=0xEC78 is actually TMR1H=0xEC????
and TMR1L=-5000>>8 is actually TMR1L=0x78.

i read in the book that TM1H and TM1L are just 8-8bit. but we are referring them 16bits.

thanks lightdiode designs my helping friend ;-)

w8t what is course BD mate..

Happy
BABAR,
;-)
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…