Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[PIC] Doubt on timer1 operation

Status
Not open for further replies.

Copper Masud

Newbie level 4
Joined
May 2, 2014
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
48
Code:
a = (TMR1L | (TMR1H<<8));   //Reads Timer Value

what happened in the timer1 code (above) ???????
 
Last edited by a moderator:

Re: timer1 ........................

TMR1L are TMR1H the low and high bytes of the timer1 16 bit value
the statement
Code:
a = (TMR1L | (TMR1H<<8));   //Reads Timer Value
1. reads TMR1L into bits 0 to 7 (low byte)
2. reads TMR1H and shifts it 8 bits left into bits 8 to 15 (high byte)
the two bytes are then bitwise ORed together to form a 16bit value which is assigned to a (which I assume is an int)
 

Re: timer1 ........................

Code:
T1CON = 0x10;                 //Initialize Timer Module
a = (TMR1L | (TMR1H<<8));   //Reads Timer Value
    a = a/58.82;                //Converts Time to Distance
    a = a + 1;                  //Distance Calibration

do you think just converting a by 58.82 will give me the distance ???????????
ow they used 8MHz oscillator and PIC16f877A
 
Last edited by a moderator:

Re: timer1 ........................

what is the algorithm?

also if you are dividing a by 58.82 make it a float variable
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top