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.

Pic16f877 timer 0 problem.

Status
Not open for further replies.

rajtech

Member level 2
Joined
Dec 25, 2007
Messages
45
Helped
4
Reputation
8
Reaction score
2
Trophy points
1,288
Activity points
1,569
Hi,
I am using pic17f877 to measure motor speed in RPM.
I connect sensor output(pulse) to RB0 interrupt.
Turn ON Timer0 and check the RB0 pin for every 1 sec to count the pulse and then multiply the data with 60 to get RPM -- per 1 min.
Here is my code, Pls help me to check and advice me , is this is the correct way of calculate the RPM. tHANKS.

CRYSTAL FREQ: 4 MHZ

if (TMR0 ==250 ){
TMR0 = 0;
SEC ++;


if(SEC == 1000 ){ //
RPM = (count/8)*60;
SEC = 0;

}
}
/////////////////////////////////////

static void interrupt
isr()
{

if(INTF==1)
{
INTF=0;
count++;

}
}
 

You have totally misunderstood the point of a timer. Read the Timer0 descritpion in PIC16F877 datasheet or the "Mid-Range MCU" information document provided on the microchip website.
 

Use the Timer0 interrupt for sampling. Use INTERRUPTS. Don't poll the value in main().
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top