M5213EVB interrupt problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

M5213EVB interrupt problem

ソリューションへジャンプ
5,938件の閲覧回数
airswit
Contributor III
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.
タグ(1)
0 件の賞賛
返信
1 解決策
2,573件の閲覧回数
airswit
Contributor III
alright, well i figured out that it is catching within the cpu_pause function once it is interrupted. i sort of fixed the problem by changing the following:

while ( (MCF_DTIM2_DTER & MCF_DTIM_DTER_REF) == 0)
{};

to:

while ( MCF_DTIM2_DTMR !=0 && (MCF_DTIM2_DTER & MCF_DTIM_DTER_REF) == 0)
{};


also, i added a second cpu_pause for the interrupts, though i havn't yet tried to just use 1 function with the alteration. now, i have a new problem though: when i run the debugger in codewarrior (v6.2) both buttons work fine, and they can interrupt each other fine. but when i just run it (no debug) the level 5 edgeport interrupt haults the system. does anyobody have a clue why that would happen

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
2,574件の閲覧回数
airswit
Contributor III
alright, well i figured out that it is catching within the cpu_pause function once it is interrupted. i sort of fixed the problem by changing the following:

while ( (MCF_DTIM2_DTER & MCF_DTIM_DTER_REF) == 0)
{};

to:

while ( MCF_DTIM2_DTMR !=0 && (MCF_DTIM2_DTER & MCF_DTIM_DTER_REF) == 0)
{};


also, i added a second cpu_pause for the interrupts, though i havn't yet tried to just use 1 function with the alteration. now, i have a new problem though: when i run the debugger in codewarrior (v6.2) both buttons work fine, and they can interrupt each other fine. but when i just run it (no debug) the level 5 edgeport interrupt haults the system. does anyobody have a clue why that would happen
0 件の賞賛
返信
2,573件の閲覧回数
airswit
Contributor III
well, I found out that the problem i was having with the board halting was the printf statement. Once I removed that, the system operated fine in both debug mode and 'run' mode.
0 件の賞賛
返信