// ******************************************************************************************* // // Include file for PIC24FJ64GA002 microcontroller. This include file defines // MACROS for special function registers (SFR) and control bits within those // registers. #include "p24fj64ga002.h" // ******************************************************************************************* // // Configuration bits for CONFIG1 settings. // // Make sure "Configuration Bits set in code." option is checked in MPLAB. // This option can be set by selecting "Configuration Bits..." under the Configure // menu in MPLAB. // // These settings are appropriate for debugging the PIC microcontroller. If you need to // program the PIC for standalone operation, change the COE_ON option to COE_OFF. _CONFIG1( JTAGEN_OFF & GCP_OFF & GWRP_OFF & BKBUG_ON & COE_ON & ICS_PGx1 & FWDTEN_OFF & WINDIS_OFF & FWPSA_PR128 & WDTPS_PS32768 ) // ******************************************************************************************* // // Configuration bits for CONFIG2 settings. // Make sure "Configuration Bits set in code." option is checked in MPLAB. // This option can be set by selecting "Configuration Bits..." under the Configure // menu in MPLAB. _CONFIG2( IESO_OFF & SOSCSEL_SOSC & WUTSEL_LEG & FNOSC_PRIPLL & FCKSM_CSDCMD & OSCIOFNC_OFF & IOL1WAY_OFF & I2C1SEL_PRI & POSCMOD_XT ) // ******************************************************************************************* // int main(void) { // TRISB controls direction for all PORTB pins, where 0 -> output, 1 -> input. // Configure RB15-RB12 as outputs. _TRISB15 = 0; // Initialize LED to off _LATB15 = 1; // TODO: Set Timer1's Prescaler to 1:256 // TODO: Set Timer 1's period value regsiter (PR1) to value for 250ms. // Clear Timer value (i.e. current tiemr value) to 0 TMR1 = 0; // TODO: Clear Timer 1 interrupt flag to detect first interupt. // TODO: Enable the interrupt for Timer 1 // Start Timer 1 T1CONbits.TON = 1; while(1) { // Nothing to see here. Move along everybody. } return 0; } // ******************************************************************************************* // // Defines an interrupt service routine that will execute whenever Timer 1's // count reaches the specfied period value defined within the PR1 register. // // _ISR and _ISRFAST are macros for specifying interrupts that // automatically inserts the proper interrupt into the interrupt vector // table // // _T1Interrupt is a macro for specifying the interrupt for Timer 1 // // The functionality defined in an interrupt should be a minimal as possible // to ensure additional interrupts can be processed. void _ISR _T1Interrupt(void) { // TODO: Clear Timer 1 interrupt flag to allow another Timer 1 interrupt to occur. _LATB15 = ~(_LATB15); } // ******************************************************************************************* //