Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 14th December 2004, 03:53 PM   (permalink)
Default Interrupt routine question - PIC16F877

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
Neil1000 is offline  
Old 14th December 2004, 06:05 PM   (permalink)
Default

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.
spirosd is offline  
Old 14th December 2004, 06:41 PM   (permalink)
Default

Why exactly do you want to do this? - why not just run the timer twice as fast and use just one edge?.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is online now  
Old 14th December 2004, 06:45 PM   (permalink)
Default

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
}

}
pop is offline  
Reply

Bookmarks

Thread Tools
Display Modes





All times are GMT. The time now is 04:28 PM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker