Hace algún tiempo estoy intentando prender y apagar un led cuando se presiona un botón, en internet he visto muchos códigos y tutoriales pero ninguno me a funcionado, no se si es un problema del simulador o no estoy programando bien el PIC.
#include <p18cxxx.h>
#include <usart.h>
#pragma config FOSC = INTIO67
#pragma interrupt high_isr
#pragma code high_vector=0x08
void interrupt_at_high_vector(void)
{
_asm GOTO high_isr _endasm
}
#pragma code /* return to the default code section */
void high_isr (void)
{
LATCbits.LATC0 ^= 1;
INTCONbits.INT0IF = 0;
}
void main (void)
{
OSCCONbits.IRCF = 0b110; //change Fosc to 8Mhz
// wait until IOFS = 1 (osc. stable)
while (!OSCCONbits.HFIOFS)
TRISBbits.TRISB0 = 1; // Se configura el puerto B0 como entrada
INTCONbits.GIE = 1; // Habilita todas las interrupciones no enmascaradas
INTCONbits.INT0E = 1; // Habilita las interrupciones externas int0 int1 e int2
INTCONbits.RBIE = 1;
INTCONbits.RBIF = 1;
INTCON2bits.INTEDG0 = 1; // Habilita la interrupcion cuando se produce un cambio de 0 a 1
INTCONbits.INT0IF = 0; // Limpia la bandera de interrrupcion en el pin RB0
TRISCbits.TRISC0 = 0; // Se configura el puerto C0 como salida
//LATCbits.LATC0 = 0; // LED output
while (1)
{
}
}
Adjunto el diagrama del circuito que estoy usando. Como simulador uso Proteus 8 y como herramienta de desarrollo mplab v8.92 con el c18 compiler v3.46.
Gracias..
