EXTERNAL INTERRUPTS
Chapter 4 External Interrupt Examples
© Fujitsu Microelectronics Europe GmbH
- 15 -
MCU-AN -300203-E-V17
Q
void
main (
void
)
{
PDR00 = 0x00;
// clear port data
DDR00 = 0xFF;
// set port 0 to output
Init_extint0();
Init_extint1();
InitIrqLevels();
__set_il(7);
// allow all levels
__EI();
// globally enable interrupts
EIRR0_ER1 = 0;
// clear ext. int 1 request flag
ENIR0_EN1 = 1;
// enable ext. int1
status = RUNMODE;
while
(1)
{
if
(status == STOPREQUEST)
// stop mode request
{
PDR00 = 0x0F;
SMCR = 0x03;
// goto stop mode, preserve pin state
}
else
// run mode
{
for
(i = 0; i < 50000; i++)
// wait loop
{
__asm(" NOP");
__asm(" NOP");
}
PDR00++;
// show, that MCU is running
}
}
}
// ISR external Int 0
__interrupt
void
IRQ_extint0 (
void
)
{
status = RUNMODE;
EIRR0_ER0 = 0;
// clear ext. int 0 request flag
ENIR0_EN0 = 0;
// disable ext. int0
EIRR0_ER1 = 0;
// clear ext. int 1 request flag
ENIR0_EN1 = 1;
// enable ext. int1
}
// ISR external Int 1
__interrupt
void
IRQ_extint1 (
void
)
{
status = STOPREQUEST;
EIRR0_ER0 = 0;
// clear ext. int 0 request flag
ENIR0_EN0 = 1;
// enable ext. int0
EIRR0_ER1 = 0;
// clear ext. int 1 request flag
ENIR0_EN1 = 0;
// disable ext. int1
}