When I try to compile the Timer1 interrupt example for the PIC32MX460F512L
from the Compiler examples Folder
I get Failed with no errors and no error hint is given ,however the EnableInterrupt Function
in the initialization code remains underlined in Red as if the compiler does not find this function
I then made a new Project and used the Interrupt tool to generate me the interrupt handler for
Timer 1 this Interrupt handler does not compiler !!
I did read the Help file
Code: Select all
/*
* Project name:
Timer1_interrupt (Timer1 interrupt test)
* Copyright:
(c) Mikroelektronika, 2009.
* Revision History:
20091106:
- Initial release;
* Description:
This code demonstrates how to use Timer1 and it's interrupt.
Program toggles LEDs on PORTB.
* Test configuration:
MCU: P32MX460F512L
http://ww1.microchip.com/downloads/en/DeviceDoc/61143G.pdf
Dev.Board: LV32MX v6
http://www.mikroe.com/eng/products/view/462/lv-32mx-v6-development-system/
Oscillator: XT-PLL, 80.000MHz
Ext. Modules: None.
SW: mikroC PRO for PIC32
http://www.mikroe.com/eng/categories/view/89/pic32-compilers/
* NOTES:
- Use the ORG directive to declare your procedure as an interrupt service routine.
The address after the ORG statement indicates which interrupt you will assign to
your procedure.
Please consult the datasheet for your MCU for interrupt vector table
details and available addresses.
- Also, consult mikroC PRO for PIC32 help on how to use interrupts.
*/
void Timer1_interrupt() iv IVT_TIMER_1 ilevel 7 ics ICS_SRS
{
T1IF_bit = 0; // Clear T1IF
LATB = ~ PORTB; // Invert PORTB
}
void main() {
AD1PCFG = 0xFFFF; // Initialize AN pins as digital
TRISB = 0; // initialize PORTB as output
LATB = 0xAAAA; // Initialize PORTB value
TMR1 = 0; // reset timer value to zero
PR1 = 65535; // Load period register
T1IP0_bit = 1; // set interrupt
T1IP1_bit = 1; // priority
T1IP2_bit = 1; // to 7
TCKPS0_bit = 1; // Set Timer Input Clock
TCKPS1_bit = 1; // Prescale value to 1:256
EnableInterrupts(); // Enable all interrupts
T1IE_bit = 1; // Enable Timer1 Interrupt
ON__T1CON_bit = 1; // Enable Timer1
}
Code: Select all
//------------------------------------------------------------------------
void MC_Init(void);
//-------------------------------------------------------------------------
void main()
{
DDPCONbits.JTAGEN = 0;
TRISA = 0;
PORTA = 0;
MC_Init();
while(1)
{
LATA.B0 = ~PORTA.B0;
Delay_ms(500);
}
}
//--------------------------------------------------------------------------
//Timer Interrupt
//--------------------------------------------------------------------------
void Timer1_Interrupt() iv IVT_TIMER_1 ilevel 7 ics ICS_SRS
{
T1IF_bit = 0; // Clear T1IF
LATB.B1 = ~ PORTB.B1; // Invert PORTB
}
//-------------------------------------------------------------------------
void MC_Init()
{
AD1PCFG = 0xFFFF; // Initialize AN pins as digital
TRISB = 0; // initialize PORTB as output
LATB = 0xAAAA; // Initialize PORTB value
TMR1 = 0; // reset timer value to zero
PR1 = 65535; // Load period register
T1IP0_bit = 1; // set interrupt
T1IP1_bit = 1; // priority
T1IP2_bit = 1; // to 7
TCKPS0_bit = 1; // Set Timer Input Clock
TCKPS1_bit = 1; // Prescale value to 1:256
EnableInterrupts(); // Enable all interrupts
T1IE_bit = 1; // Enable Timer1 Interrupt
ON__T1CON_bit = 1; // Enable Timer1
}