#include <xc.h> #include<plib/timers.h> #define _XTAL_FREQ 40000000 unsigned char config1; unsigned int timer_value; unsigned int tpr; int counter=0; void main(void) { TRISBbits.RB3 = 0; PORTBbits.RB3 = 0; // 1/1 prescalar T1CONbits.T1CKPS1 = 1; T1CONbits.T1CKPS0 = 1; // Use Internal Clock T1CONbits.TMR1CS = 0; // Timer1 overflow interrupt PIE1bits.TMR1IE = 1; // Enable Timer 1 T1CONbits.TMR1ON = 1; INTCONbits.PEIE = 1; // Enable Perpherial Interrupt INTCONbits.GIE = 1; // Enable Global Interrupt while(1) { } } void interrupt high_priority lowISR(void) { if (PIR1bits.TMR1IF == 1) { if(counter == 0) { PORTBbits.RB3 = 1; counter = 1; } else if(counter == 1) { PORTBbits.RB3 = 0; counter = 0; } TMR1 = 0X00; PIR1bits.TMR1IF = 0; } } Second of all, I'm working with PIC18F2520 with XC8 compiler and I want to receive an infrared code. For that, I need to work with Timers for the signal's reading, but I dont get it working. I've been looking for this topic and I haven't find it.
Tip: Pragma settings are written in other file.
When I run this code in proteus, seems to do anything. What could be the problem? Btw, actually I'm using my PIC18 with an external oscillator.
What could be the problem? could be the pragma definitions?