Continue to Site

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.

  • 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.

Interrupt routine question - PIC16F877

Status
Not open for further replies.

Neil1000

New Member
Hi,

Does anyone know if it possible to set up an interrupt routine that will trigger off both the rising and falling clock pulses? In my code I want to set an interrupt that will make pin RA0 HI a set time delay after the first rising clock edge and then will make RA0 go LO on the falling clock pulse. Is this possible using Timer1 of the 16F877?

Thanks

Neil
 
Timer1 can be configured (timer / counter modes) to increment on either the rising edge of the external clock or on every instruction cycle. So the answer is no.

Perhaps :roll: it might be possible using the two CCP modules (configure one to interrupt on rising edge the other on falling edge.
 
This is possible. Like spirosd said you'll need to use a ccp module.

Here is the pseudocode:

#bit INTERUPT_EDGE=0x81.6 //intedg is in option register

main()
{

INTERUPT_EDGE=1; //trigger at rising edge
}

interrupt_isr() //interrupt service routine
{
CCP1=100; //load whatever value you want
timer1=0; //reset timer1
}

ccp_isr() //occurs when ccp1 == timer1
{
if (RA0 == LOW)
{
CCP+=DELAY; //delay value
Output_high(RA0);
}
else
{
Output_low(RA0);
INTEDGE=0; //falling edge
}

}
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top