I want to capture the ONOFF button press, and am enabling SNVS_PULSE_EVENT_IRQn, however the handler constantly fires with HPSR reserved bits in addition to bit 7, the button interrupt I am capturing when the button is pressed.
However this constant firing of the SNVS_PULSE_EVENT_IRQHandler slows the program down, how can I eliminate this?
已解决! 转到解答。
I believe there must be something wrong with your hardware connection of the button. I implemented the code you shared on the EVK, and I only see the handler trigger once. By the way, I don't recommend adding a printf() routine inside of an IRQ Handler: multithreading - C printf() in interrupt handler? - Stack Overflow
BR,
Edwin.
The SNVS_PULSE_EVENT_IRQn only gets triggered by bit 7 of the SNVS_HP Status Register (HPSR). Please make sure your button connection properly made to prevent bouncing issues, and clear the interruption bit between triggers by writing 1 on bit 7 of the HPSR.
BR,
Edwin.
Thank you for the response, however I am doing this, but the handler is constantly called no matter what. So right after the call to "EnableIRQ( SNVS_PULSE_EVENT_IRQn );", no other statement is executed as the IRQ handler is constantly called with the reserved bits being set, and slowing the program down. Yes, I properly get the button press when pressed, i.e. the statement: "PRINTF( "SNVS_PULSE_EVENT_IRQHandler.\r\n" );" is called only at button press, but the "SNVS_PULSE_EVENT_IRQHandler" is always called constantly.
Code to set / capture IRQ:
SNVS_HP_Init( SNVS );
SNVS->HPCR |= SNVS_HPCR_BTN_MASK( 0x01 ); // 1: Interrupt enabled
SNVS->HPCR |= SNVS_HPCR_BTN_CONFIG( 0x02 ); // 010: Button signal is active on the falling edge
EnableIRQ( SNVS_PULSE_EVENT_IRQn );
Handler code:
void SNVS_PULSE_EVENT_IRQHandler(void)
{
if( ( SNVS_HP_GetStatusFlags( SNVS ) & SNVS_HPSR_BI_MASK ) != 0U )
{
PRINTF( "SNVS_PULSE_EVENT_IRQHandler.\r\n" );
SNVS_HP_ClearStatusFlags( SNVS, SNVS_HPSR_BI_MASK );
}
SDK_ISR_EXIT_BARRIER;
}
I believe there must be something wrong with your hardware connection of the button. I implemented the code you shared on the EVK, and I only see the handler trigger once. By the way, I don't recommend adding a printf() routine inside of an IRQ Handler: multithreading - C printf() in interrupt handler? - Stack Overflow
BR,
Edwin.
Sure, I know printf’s are not to be used, this is just debug/test code.
I thought I had tested this same code on the EVKB board with the same results, I.e. multiple Irq firings, but can test again.
could you share your test project so I can make sure I’m testing apples to apples?