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.

The equation for converting from value of TMR1L in timer 1 into microseconds

Status
Not open for further replies.

NadaF

Newbie level 6
Newbie level 6
Joined
May 1, 2013
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,364
i need equation to convert value in TMR1L into microseconds on pic 16f877a using mikroc language plzzz anyone help me !!!! :(

- - - Updated - - -

my code using mikroc language:
i'm using pic 16f877a , timer1, internal clock
int Dis;
int Dur;
int T;
void main()
{
TRISB.B7=1; // i/p for pic
TRISB.B6=0; // o/p for pic
while (1)
{
if (PORTB.B6=1)
{
T1CON=0001001; // timer on
if (PORTB.B7=1)
{
T1CON=00000000; // timer off
}
T= TMR1L;
Dur=T/4/1; // lsa freq of osc. /4 / prescaler rate 1:1 -----> is that convert value into microseconds ?!
Dis=(Dur/29.1)/2;

}
}
}
 

If you had a 4MHz xtal, then the instruction cycle time is 1MHz which is 1uS.
The timer is incremented at the instruction cycle rate, so with a prescaler of 1:1, each count is 1uS.
 
  • Like
Reactions: NadaF

    NadaF

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top