2012-03-16 05:33 AM
i am using eCos for my app. i have STM3210E-EVAL board.
in my app there is one thread(toggle LED) and external interrupt on PG8. when button is pressed(PG8) another LED should blink once.but nothing...
unsigned
int
button_isr(cyg_vector_t vector,cyg_addrword_t data)
{
cyg_interrupt_mask(vector );
// Tell the processor that we have received
// the interrupt.
cyg_interrupt_acknowledge( vector );
// Tell the kernel that chained interrupt processing
// is done and the DSR needs to be executed next.
return
(CYG_ISR_CALL_DSR);
}
void
button_dsr(cyg_vector_t vector, cyg_ucount32 count, cyg_addrword_t data)
{
k=~k;
CYGHWR_HAL_STM32_GPIO_OUT(led_f6,k);
delay(100);
cyg_interrupt_unmask(vector);
}
void
threadA(cyg_addrword_t index)
{
while
(1)
{
CYGHWR_HAL_STM32_GPIO_OUT(led_f7,1);
cyg_thread_delay(500);
CYGHWR_HAL_STM32_GPIO_OUT(led_f7,0);
cyg_thread_delay(500);
}
}
int
main(
void
)
{
cyg_handle_t int1;
cyg_interrupt intr;
cyg_thread_create(15,threadA,0,
''threadA''
,&ON,STACK,&led_on,&led_on_obj);
//toggle LED
cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_EXTI8, 1, (cyg_addrword_t)0, &button_isr,&button_dsr, &int1, &intr);
// Set interrupt configuration
cyg_interrupt_configure(CYGNUM_HAL_INTERRUPT_EXTI8,0,1);
//rising edge.....
// level| up | interrupt on
// -----|-------|-----------------
// 0 | 0 | Falling Edge
// 0 | 1 | Rising Edge
// 1 | 0 | Low Level
// 1 | 1 | High Level
cyg_interrupt_attach(int1);
cyg_interrupt_enable();
cyg_interrupt_unmask(CYGNUM_HAL_INTERRUPT_EXTI8);
cyg_thread_resume( led_on );
return
0;
}
help...
thanks....
Filip
#ecos #exti #interrupt
2012-03-16 09:52 AM
So how and where are you initializing the GPIO, EXTI, peripheral clocks, etc.
2012-03-19 01:41 AM
the initialization of EXTI is done by OS....
initialization of GPIO is done by function initialization()...in previous post a forget it...void
initialisation(
void
)
{
HAL_WRITE_UINT32(0x40021018,0x00000180);
//enable clock for PORT G & PORT F
HAL_WRITE_UINT32(0x40010010,0x00000006);
//set PIN_8 of port 8 as interrupt input
k=0;
down=CYGHWR_HAL_STM32_GPIO(G,8,IN,FLOATING);
//button
CYGHWR_HAL_STM32_GPIO_SET(down);
led_f6=CYGHWR_HAL_STM32_GPIO(F,6,OUT_50MHZ,GPOPP);
//out pin
CYGHWR_HAL_STM32_GPIO_SET(led_f6);
}
thanks for reply.....
Filip.
2012-03-19 04:47 AM
I believe you will also need to enable the APB2 SYSCFG unit for EXTI
You should also probably avoid blind writes into configuration registers, and instead mask in the content you want. There will be less traps for you to fall in down the road.2012-03-19 06:04 AM
2012-03-19 06:54 AM
Oops, was thinking you had an F2 or F4, with the high pin banks.
On the F1 you'll need to enable the AFIO unit for EXTI2012-03-20 01:25 AM
it's working now....the problem was function call
cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_EXTI8, 1, (cyg_addrword_t)0, &button_isr,&button_dsr, &int1, &intr);
arg4 and arg5 are pointers to ISR and DSRrespectively.....
so correct function call is
cyg_interrupt_create(CYGNUM_HAL_INTERRUPT_EXTI8, 1, (cyg_addrword_t)0, button_isr,button_dsr, &int1, &intr);
button_isr and button_dsr without &....
Filip.
2014-05-04 09:27 PM
i follow your program, but it didn't work. if i put the handle code all in the isr function, it works!
Finally I find out thatcyg_handle_t int1,
cyg_interrupt intr should be global varibles.