Mikroelektronika MIKROE-738 Datenbogen
![Mikroelektronika](https://files.manualsbrain.com/attachments/e0529b3b58069a916ad7bb89f7e9f5f0eda73421/common/fit/150/50/1b07b99aa3112e022a916b06db07f1f4f211e91d41878452d87c7638b1bf/brand_logo.gif)
144
mikoC PRO for PIC32
MikroElektronika
Interrupt Example
Here is a simple example of handling the interrupts from
Timer1
(if no other interrupts are allowed):
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
}