• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

single stepping increment a 16bit Timer

Status
Not open for further replies.

hhhsssmmm

New Member
Hello

I have PIC18F2420 running via 4MHz ceramic resonator....and the compiler is used C18.

I can single step increment TMR0 (8bit mode) just by changing TMR0L regsiter value from 00 - FF. So lets....

TMR0L = 0;

So i can change the TMR0 interrupt every single step just by the command TMR0L++...(that is from 256us all the way to 1us).

Now my question is, how can i perform similar single stepping for a 16bit timer? Im confused and therefore im asking since 16bit timer has two registers to initiallize....for example for timer1 is initiallized from 5ms and you wish to single step it by incrementing it to 10ms....we have...

5ms intiallized TMR1
-------------------
TMR1L = 78;
TMR1H = EC;

.....so from here how would you, in a similar 8bit fashion, single step a 16bit timer all the way to 10ms?


Please can some one help me here?

thank you
haseeb
 

Mr RB

Well-Known Member
Hello

I have PIC18F2420 running via 4MHz ceramic resonator....and the compiler is used C18.

I can single step increment TMR0 (8bit mode) just by changing TMR0L regsiter value from 00 - FF. So lets....

TMR0L = 0;

So i can change the TMR0 interrupt every single step just by the command TMR0L++...(that is from 256us all the way to 1us).

Now my question is, how can i perform similar single stepping for a 16bit timer? Im confused and therefore im asking since 16bit timer has two registers to initiallize....for example for timer1 is initiallized from 5ms and you wish to single step it by incrementing it to 10ms....we have...

5ms intiallized TMR1
-------------------
TMR1L = 78;
TMR1H = EC;

.....so from here how would you, in a similar 8bit fashion, single step a 16bit timer all the way to 10ms?
...
That sounds like you want to inc the timer by 1. ie; add 1 to the timer value.

in C;
TMR1L++;
if(TMR1L==0) TMR1H++;

So you add 1 to TMR1L, then if it rolls over to 00 you add 1 to TMR1H.
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top