Wake up after WFI

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Not applicable
Hello to all,

I am programminga device and want to have the processor go into sleep mode. I used the WFI instruction, which if I understand correctly enters the processor into sleep mode until an interrupt is fired and then it wakes up. Right now the processor goes to sleep but does not wake up when the interrupt is fired.
The exact situation:
The interrupt is provided by a pad signal from one of the pins using IO002. When I monitor the voltage using a multimeter I can see that the voltage does indeed rise on that pin, but that is not recognised by the processor.
Does anyone know how I can fix that? Or if there is a better way to enter and exit sleep mode?

Cheers,
Ahmed
0 Likes
2 Replies
MichaelIFX
Employee
Employee
50 replies posted 25 replies posted 10 replies posted
Dear Ahmed,
as you mention IO002 it appears you are still working with DAVE3.
If there are no good reasons to stay with DAVE3 (like legacy projects), I would propose using DAVE4 which improved in many aspects and makes sure your new project state of the art.

From your description it is not clear to me, if the interrupt fires and you end up inside you ISR even without applying SLEEP-mode? Only if this works let's move on and apply the interrupt to wakeup from SLEEP.
To trigger an interrupt from a pin you need to connect it to a ISR node. Pins/Ports are not connected directly to an ISR node. Instread you need to wire the pin through the ERU to an ERU IRQ-handler.

For this purpose you need the following APPS:
DIGITAL_IO, EVENT_GENERATOR, EVENT_DETECTOR

Inside HW signal connections apply the following wiring:
DIGITAL_IO/pin ->EVENT_DETECTOR/signal_a
EVENT_DETECTOR/trigger_out -> EVENT_GENERATOR/trigger_in
EVENT_GENERATOR/iout -> INTERRUPT_0/sr_irq

Next:
- Configure EVENT_DETECTOR APP to use Rising Edge detection and select Source A.
- Assign the input pin inside DIGITAL_IO-APP/"Manual Pin Allocator".
- Implement an empty ISR:
void UserIRQHandler(void)
{
return;
}


Place an breakpoint on the return and start debugging.
Check the breakpoint is triggered on an rising edge of the input pin you have selected.

Michael
0 Likes
enrico_b
Employee
Employee
First like given 10 sign-ins 5 solutions authored
Hi Michael,

I am trying to get the same behavior using XMC1100. I followed your instructions and I am able to generate an interrupt using a PIN event.
I then put the device in deep sleep mode using this code:

void sleep(void) {
//TIMER_ClearEvent(&TIMER_SLEEP);
// The clock of the peripherals that are not needed during sleep state can be gated before entering sleep state
XMC_SCU_CLOCK_GatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_CCU40);
XMC_SCU_CLOCK_GatePeripheralClock(XMC_SCU_PERIPHERAL_CLOCK_WDT);

// Enable FLASH power down during SLEEP and DEEPSLEEP mode
XMC_SCU_CLOCK_EnableFlashPowerDown();

// Make sure that SLEEPDEEP bit is set
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

//Disable interrupts
INTERRUPT_Disable(&INTERRUPT_UPDATE_UI);
INTERRUPT_Disable(&SCAN_TIMER_INTERRUPT);

// in deep-sleep state, the PCLK and MCLK will
// be switched to a slow standby clock and DCO1 will be put into power-down mode
// It is recommended to slow down the PCLK and MCLK before entering deep sleep
// mode to prevent a sudden load change that could cause a brownout reset.
XMC_SCU_CLOCK_SetFastPeripheralClockSource(XMC_SCU_CLOCK_PCLKSRC_MCLK);
XMC_SCU_CLOCK_SetMCLKFrequency(125);

for(int i=0; i<4; i++)
DIGITAL_IO_SetOutputHigh(COLS);
needWakeup = true;

SSD1306_switchOff();
WATCHDOG_Stop();

__WFI();
}

From that moment on, I am not able to wakeup the device anymore using the same interrupt. Can you maybe give me a hint?
Kind regards,

Enrico
0 Likes