![]() | ![]() | ![]() |
| | |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| Why exactly do you want to do this? - why not just run the timer twice as fast and use just one edge?. | |
| |
| | (permalink) |
| 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 } } | |
| |