AnsweredAssumed Answered

M5213EVB interrupt problem

Question asked by Trevor Switkowski on Mar 20, 2006
Latest reply on Mar 26, 2006 by Trevor Switkowski
Hi everyone,

I am very new to this development board/processor, and am having a bit of trouble coding a simple interrupt scheme. as you can see by the code below, the system should 'bounce' the leds back and forth forever. once a button is pressed, the system pauses, shows something else on the leds, and then i want it to return. everything is working fine, except that the system will not return back from whence it came (meaning the 'main loop'). can anybody give me any advice?



[code]

#define DELAY 100000 /* Delay in micro-seconds */
void main_loop(void);
__interrupt__ void sw1_handler(void);
__interrupt__ void sw2_handler(void);
void
board_led_display(int number)
{
/* Enable signals as GPIO */
MCF_GPIO_PTCPAR = 0
| MCF_GPIO_PTCPAR_TIN3_GPIO
| MCF_GPIO_PTCPAR_TIN2_GPIO
| MCF_GPIO_PTCPAR_TIN1_GPIO
| MCF_GPIO_PTCPAR_TIN0_GPIO;

/* Set output values */
MCF_GPIO_PORTTC = (uint8)number;

/* Enable signals as digital outputs */
MCF_GPIO_DDRTC = 0
| MCF_GPIO_DDRTC_DDRTC3
| MCF_GPIO_DDRTC_DDRTC2
| MCF_GPIO_DDRTC_DDRTC1
| MCF_GPIO_DDRTC_DDRTC0;
}

int main()
{
MCF_EPORT_EPPAR = 0
| MCF_EPORT_EPPAR_EPPA4_RISING
| MCF_EPORT_EPPAR_EPPA5_RISING
| MCF_EPORT_EPPAR_EPPA7_LEVEL;
mcf5xxx_set_handler(64 + 4, /*(ADDRESS)*/sw1_handler);
mcf5xxx_set_handler(64 + 5, /*(ADDRESS)*/sw2_handler);

main_loop();
}

void main_loop(void)
{
int i;
mcf5xxx_irq_enable();
while(1)
{
for (i = 1; i 8; i=1)
{
board_led_display(i);
cpu_pause(DELAY);
}
for (i = 8; i > 1; i>>=1)
{
board_led_display(i);
cpu_pause(DELAY);
}
}

}

__interrupt__ void
sw1_handler(void)
{
int i;
for(i=0 ; i16 ; i++)
{
board_led_display(i);
cpu_pause(DELAY);
}
MCF_EPORT_EPFR = MCF_EPORT_EPFR_EPF4;
}
__interrupt__ void sw2_handler(void)
{
board_led_display(0);
cpu_pause(2000000);
printf("Button2 pushed!\n");
MCF_EPORT_EPFR = MCF_EPORT_EPFR_EPF5;
}



[/code]



p.s. i am using the default codewarrior include files for this demo board.

Outcomes