![Freescale Semiconductor MPC5604B Скачать руководство пользователя страница 29](http://html1.mh-extra.com/html/freescale-semiconductor/mpc5604b/mpc5604b_quick-start-manual_2330604029.webp)
2.
INTC configuration (Software mode)
2.1.
Enabling interrupt requests
There are two stages for enabling interrupts; first, at a general level, the interrupt handling in
the microcontroller has to be enabled, then, at the peripheral level, for an ISR to be raised, the
registers in charge of that interrupt has to be configured.
Here’s the code for enabling interrupts at a general level:
Peripheral-level enabling of an ISR will be mentioned on that peripheral’s chapter.
2.2.
Configuring hardware ISRs
INTC is implemented in following files in a project: INTCInterrupts.h, IntcInterrupts.c,
Exceptions.h, Expcetions.c. These files possess required routines to execute the previously
explained ISR handling procedure. The following function is used to configure an ISR’s handler
and priority:
vectorNum is the ISR’s vector number (see Interrupt Vector Table), handlerFn is a
void
function
written by the user, and psrPriority is the priority between 0 and 15 (0 priority is not served).
Example: Blinking a LED when PIT1 (a timer, see following chapters) interrupt is generated.
void
enableIrq
(
void
) {
INTC
.CPR.B.PRI = 0;
/* Single Core: Lower INTC's current priority */
asm(
"wrteei 1"
);
/* Enable external interrupts */
}
void
INTC_InstallINTCInterruptHandler
(
INTCInterruptFn
handlerFn,
unsigned short
vectorNum,
unsigned char
psrPriority);
uint32_t
LED_state
= 0
;
void
PIT1_Interrupt
();
int
main
(
void
) {
initModesAndClock
();
/* Initialisation of the device
*/
config_PORT_E
();
/* Configuration of GPIO
*/
initPIT
();
/* Init the timer PIT1 to trigger ISR every 0.5sec
*/
INTC_InstallINTCInterruptHandler
(
PIT1_Interrupt
,60,2);
/* 60 is PIT1 vector
number, we choose to give a priority of 2 */
enableIrq
();
/* Enable interrupts, after interrupt configs */
for
(; ;){}
/* Main loop
*/
}
void
PIT1_Interrupt
(){
//Finite State Machine for the LED 1
if(LED_state
== 0) {
LED_state
= 1;
SIU
.GPDO[68].B.PDO = 0;
/* Set LED */
}
else
{
LED_state
= 0;
SIU
.GPDO[68].B.PDO = 1;
/* Clear LED */
}
//Clear PIT1 interrupt
PIT
.CH[1].TFLG.B.TIF = 1;
}
Содержание MPC5604B
Страница 1: ...LAAS CNRS Quick Start to MPC5604B Embedded Development Sahin Serdar 21 06 2013...
Страница 31: ...Figure 33 INTC SW HW mode comparison Freescale Tutorial...
Страница 87: ......
Страница 132: ......
Страница 133: ...127 Appendix 2 Pad Configurations...
Страница 134: ......
Страница 135: ......
Страница 136: ......
Страница 137: ......
Страница 138: ......
Страница 139: ......
Страница 140: ......
Страница 141: ...Appendix 3 Peripheral input pin selection...
Страница 142: ......
Страница 143: ...137 Appendix 4 Interrupt Vector Table...
Страница 144: ......
Страница 145: ......
Страница 146: ......
Страница 147: ......
Страница 148: ...Appendix 5 I C Baud Rate Prescaler Values...
Страница 149: ......
Страница 150: ......