SOLVED: I put here my code, I hope it helps someone! ^^ TIP: My problem was because I was comparing if PORTBbits.RB3 == 0 or == 1; the solution has been comparing a variable instead a state.
#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;
}
}
First of all, I introduce myself! I'm Manuel and as you can see I'm new on this web. I will help as much as I can!
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.
Thank you very much!.
What could be the problem? could be the pragma definitions?
EDIT: code updated in main post, sorry for all the inconvenients!