![]() | ![]() | ![]() |
| | |||||||
| 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) |
| Could anyone help me out. I have included my C code. I want to create two signals on the my PIC DEMO PLUS 2 board RA0 and RA1. I am getting an interrupt on RA0 but nothing on RA1. RB0 is my interrupt PIN. I have set all my registers according to the datasheet. but getting confused. #include <io16f877.h> #pragma vector = 0x1 __interrupt void externISR() { if(INTF) //loop controllling software design of interrupts on PIC { RA0 = 0; // ensuring RA0 set low RA1 = 0; TMR1H = 0xF6; // Pre - load timer with this value = 63035 TMR1L = 0x3B; // We want an overflow after 2500 ticks (interval of 20ms) // As (2^16 -1)-2500 = 63035 TMR2 = 0x0; TMR2IF = 0x0; TMR1IF = 0; // no interrupt flag INTF = 0; //related with INTCON register in void main, set to 0 here to clear interrupt. } else if(TMR1IF) { RA0 = 1; // RA0 set high when interrupt occurs } else if(TMR2IF) { RA1 = 1; } } void main() { TRISA = 0x0; //Set as an output on PortA TRISB = 0x1; //Set as an input on PortB RA0 = 0; // RA0 always set low RA1 = 0; INTEDG = 0x1; // Set to trigger off the rising clock edge. INTCON = 0x90; //this is our control and status of our interrupts. T1CON = 0x3d; // sets the prescaler value of clock 1:8, oscillator enabled,internal clock selected TMR1IE = 1; TMR1IF = 0; // set at zero, flags are seen when = 1 T2CON = 0x7F; TMR2IE = 1; TMR2IF = 0; PEIE = 1; PR2 = 0xFF; while(1); } | |
| |
| | (permalink) |
| Hi, There are control registers (TMR1ON, TMR2ON) that enable and disable the timers on 16f877. I did not see where they are explicitly being set. I would also personaly reset the relevant timers once the interrupt has occured (does tmr2 get reset if tmr1 has caused an interrupt?). How is the INTF being triggered? | |
| |
| | (permalink) | |
| Quote:
__________________ Rock Mental | ||
| |