1) Does any of the ISR manipulate the value of the variable "state"?
2) What is done in the ISR associated with the PICU interrupt? Restoring the clocks in that ISR seems more intuitive.
3) When the device is in Sleep mode, the IMO is turned off. So, running the device in Debug mode is not possible while in sleep. Please verify if the chip functionality is as expected when it is run normally (without running in "Debug" mode).
I had a glance at the attached code. Although I could not find the exact issue at this point, I would suggest you to try the following things.
I see that you are enabling the ISR and calling a while loop after saving clocks using CyPmSaveClocks() API. It is advisable to call CyPmSleep( ) soon after saving clocks and not to do any other functions as all the pheripheral clocks are off and could result in undesirable results. Also restore clocks as soon as the part wakes up.
CyPmReadStatus() is not necessary as the part is not waking from a CTW event.
Try keeping all component wake-up APIs outside the interrupt routine (writing soon after the restore clocks in main.c) and
thereby using ISR rotine only to clear interrup status bits/ setting flag etc..
If possible, can you attach the project here so that I can relook where exactly its goin wrong?
I would suggest you to upload your project here, so that we get a complete poicture of your picture. We can suspect few things but we can not zero in on the root cause without your complete project.