Tengo Chpkit Uno32 con PIC32MX320F128H, estoy tratando de habilitar la interrupción y he escrito el siguiente código:
// PIC32MX320F128H Configuration Bit Settings
// 'C' source line config statements
// DEVCFG3
// USERID = No Setting
// DEVCFG2
#pragma config FPLLIDIV = DIV_2 // PLL Input Divider (2x Divider)
#pragma config FPLLMUL = MUL_20 // PLL Multiplier (20x Multiplier)
#pragma config FPLLODIV = DIV_1 // System PLL Output Clock Divider (PLL Divide by 1)
// DEVCFG1
#pragma config FNOSC = PRIPLL // Oscillator Selection Bits (Primary Osc w/PLL (XT+,HS+,EC+PLL))
#pragma config FSOSCEN = OFF // Secondary Oscillator Enable (Disabled)
#pragma config IESO = OFF // Internal/External Switch Over (Disabled)
#pragma config POSCMOD = XT // Primary Oscillator Configuration (XT osc mode)
#pragma config OSCIOFNC = OFF // CLKO Output Signal Active on the OSCO Pin (Disabled)
# pragma config FPBDIV = DIV_1 // Peripheral Clock Divisor (Pb_Clk is Sys_Clk/1)
#pragma config FCKSM = CSDCMD // Clock Switching and Monitor Selection (Clock Switch Disable, FSCM Disabled)
#pragma config WDTPS = PS1048576 // Watchdog Timer Postscaler (1:1048576)
#pragma config FWDTEN = OFF // Watchdog Timer Enable (WDT Disabled (SWDTEN Bit Controls))
// DEVCFG0
#pragma config DEBUG = OFF // Background Debugger Enable (Debugger is disabled)
#pragma config ICESEL = ICS_PGx2 // ICE/ICD Comm Channel Select (ICE EMUC2/EMUD2 pins shared with PGC2/PGD2)
#pragma config PWP = OFF // Program Flash Write Protect (Disable)
#pragma config BWP = OFF // Boot Flash Write Protect bit (Protection Disabled)
#pragma config CP = OFF
#include <p32xxxx.h>
#include <sys/attribs.h>
void __ISR(_TIMER_1_VECTOR, ipl4) Handler(void) {
LATFbits.LATF0 = ~LATFbits.LATF0;
IFS0bits.T1IF = 0; // Clear interrupt flag
}
int main() {
T1CONbits.TCKPS = 3;
PR1 = 0xFFFF;
IEC0bits.T1IE = 1; // Enable Interrupt for Timer 1
IFS0bits.T1IF = 0; // Clear interrupt flag for Timer 1
T1CONbits.ON = 1;
__asm__("EI");
TRISFbits.TRISF0 = 0;
LATFbits.LATF0 = 1;
while (1);
return 0;
}
PD: Sé que esta pregunta se repite, pero leí la mayor parte de la hoja de datos y el manual de referencia y me quedé atascado por un tiempo.