Welcome in the forum!
You try to reset the interrupt with
, but BTNConfig is your I/O-pin component which does not generate an interrupt by itself.
You may use isr_BTNConfig_ClearPending() which would clear your interrupt.
Furthermore you might get a lot of pulses. When you get one when releasing the button you do not clear the interrupt.
Local variables do not need to be declared as "volatile", only globals need that.
It is not a good idea to wait for several seconds with all interrupts switched off. When the project is expanded to do more jobs this might stall the system. I would suggest you to change the logic to using a flag and poll for it in main().
When debugging it may look as if you "hang" in an interrupt handler, do not single-step. Use breakpoints to stop your program.
Thank you very much for your help and advices. I did the BTNConfig_ClearInterrupt() and the isr_BTNConfig_ClearPending() before but it did not work out, so I remove it (not the best idea - I will put it back as I know i may cause some issue in the future).
Regarding the wait inside the interrupt, I will try to implement it in the main routine setting just a flag inside the interruption. I know it is a better coding to do so.
I opened a Case along with Cypress regarding this same issue. And apparently it is working now. The problem was within the XBEE_Reconditec.c file in the XBEE_RxDataHandler function. While in the IDLE state, the RxBufferIndex kept incrementing for no reason (even if there is no data in the SCB Rx Buffer). Therefore, I managed to move the Packet->Data[RxBufferIndex++] to inside the if(ReceivedByte == XBEE_StartDelimiter) and also moved the entire switch statement to a new if(XBEE_UART_SpiUartGetRxBufferSize() != 0u) as there is no need to go for the switch if there is no data in the Rx Buffer.
I will perform these changes and I hope the code runs smooth!
Thank you again for your help.
Hi Bob, I have a similar problem in my code, I have to disable and enable continuously some interrupts and for some reason the code jump to the infinite loop CY_ISR(IntDefaultHandler) in Cm3Start.c.
In the class Interrupt.c and Interrupt.h I have the manage to start, stop and execute all the interrupts of my application, do you have any idea how to fix this problem??, I attach the workspace and the interest project name is Calima2.
Thanks in advance.
Quite a complex project! I would try using / interpreting the call stack to see where the program flow came from. The interrupt is usually called in case of an error as addressing memory that doesn't exist, executing invalid instructions and other mishaps. Usually caused by bad pointers, clobbered stack or arrays out of bounds. Does your debug variables show any hint?