timer1 for 12f675 'int' question

Status
Not open for further replies.

DMW

New Member
Hello, im trying to make a delay with timer 1 from 0 to 10ms using the .
on-board 1mhz instruction clock with a 1:1 prescaller,

the timer1 has two 8-bit registers -tmr1L and tmr1h,
if i need to increment my delay, so i make a variable:
unsigned shot int delay=0xFFFF;

so now im my code i can happily add and subtract values from my delay, but how can i turn this int into two 8 bit 'chars' so i can then write them to the timer values.

thanks for any help, i dont fancy using two 8 bit values to hold my delay as that complicates adding and subtracting values - but i may have too.
 
nevermind, it may not be the correct way of doing things but:
TNR1L=delay;
and
TMR1H=delay>>8;

seems to work...
 
nevermind, it may not be the correct way of doing things but:
TNR1L=delay;
and
TMR1H=delay>>8;

seems to work...

hi,
Its important to remember the time delay [ if you are using tmr1 to generate an interrupt]
that the intr occurs when the tmr1H and tmr1L roll over. [ffff > 0000]

So you have to load the tmr1 regs with the difference between ffff> 0000.
Your tmr1H and tmr1L have to be reloaded when the intr occurs.

I dont program in 'C', but isnt there a xxx.HB and xxx.LB or a similar command.?

Do you follow OK.
 
Last edited:
You should get a copy of the "PICmicro™ Mid-Range MCU Family Reference Manual"
You will find alot of information in there also some ASM samples which can be converted to C with some knowledge.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…