cancel
Showing results for 
Search instead for 
Did you mean: 

interrupt handling

kantarofilip
Associate II
Posted on March 16, 2012 at 13:33

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
7 REPLIES 7
Posted on March 16, 2012 at 17:52

So how and where are you initializing the GPIO, EXTI, peripheral clocks, etc.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kantarofilip
Associate II
Posted on March 19, 2012 at 09:41

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.
Posted on March 19, 2012 at 12:47

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kantarofilip
Associate II
Posted on March 19, 2012 at 14:04

thanks for suggestions....

i am using stm32f10 and as i know there is no SYSCFG.....

thanks again,

Filip.

Posted on March 19, 2012 at 14:54

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 EXTI
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
kantarofilip
Associate II
Posted on March 20, 2012 at 09:25

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.
huangyg11
Associate II
Posted on May 05, 2014 at 06:27

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 that

cyg_handle_t int1,
cyg_interrupt intr should be global varibles.