Reply
Posts: 3
Registered: ‎03-16-2017

PB13 cannot wakeup from EM2 on EFM32ZG110

hi, I had set two interrupt on PC14 and PB13, but only PC14 can work --- wake up on EM2

and after wake up, I can see the earlier PB13 prints...

 

GPIO_PinModeSet(KEY_PORT, KEY_PIN, gpioModeInputPullFilter, 1);  //PC14
GPIO_IntConfig(KEY_PORT, KEY_PIN, TRUE, TRUE, TRUE); //test


GPIO_PinModeSet(KEY2_PORT, KEY2_PIN, gpioModeInputPullFilter, 1);  //PB13
GPIO_IntConfig(SENSOR_PORT, SENSOR_PIN, FALSE, TRUE, TRUE);

.....

NVIC_EnableIRQ(GPIO_ODD_IRQn);
NVIC_EnableIRQ(GPIO_EVEN_IRQn);

....

void GPIO_EVEN_IRQHandler(void)
{
GPIO_IntClear(1<<KEY_PIN);
RTT_PRINT("key pressed @@@@\r\n");
}
void GPIO_ODD_IRQHandler(void)
{
GPIO_IntClear(1<<SENSOR_PIN);
RTT_PRINT("sensor pressed ####\r\n");
}

.....

.....

EMU_EnterEM2(false); 
SMOKE_PRINT("****** Wake Up ******\r\n");

Posts: 490
Registered: ‎02-04-2013

Re: PB13 cannot wakeup from EM2 on EFM32ZG110


alixx wrote:

 

GPIO_PinModeSet(KEY2_PORT, KEY2_PIN, gpioModeInputPullFilter, 1);  //PB13
GPIO_IntConfig(SENSOR_PORT, SENSOR_PIN, FALSE, TRUE, TRUE);

 


What's the difference between KEY2 defines and SENSOR defines?  Are they supposed to be the same?  You should include the definitions of any symbols in your posted code.

 

Can you post waveforms/schematics?  It looks like you're setting up PC14 for rising/falling interrupts and SENSOR for just falling interrupt.  Is that intentional?

 

Where's the code that would print that PB13 interrupt fired?

 

Best regards,

Chris

Posts: 3
Registered: ‎03-16-2017

Re: PB13 cannot wakeup from EM2 on EFM32ZG110

hi Chris, here is the full scripts, sorry for the mistake.  

BTW,how to modify the posted contents?


#include "SEGGER_RTT_conf.h"
#include "SEGGER_RTT.h"

#define KEY_PORT gpioPortB
#define KEY_PIN 13

#define KEY2_PORT gpioPortC
#define KEY2_PIN 14

void GPIO_Init(void)
{
GPIO_PinModeSet(KEY_PORT, KEY_PIN, gpioModeInputPullFilter, 1);
GPIO_IntConfig(KEY_PORT, KEY_PIN, TRUE, TRUE, TRUE);

GPIO_PinModeSet(KEY2_PORT, KEY2_PIN, gpioModeInputPullFilter, 1);
GPIO_IntConfig(KEY2_PORT, KEY2_PIN, TRUE, TRUE, TRUE);

NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
NVIC_EnableIRQ(GPIO_ODD_IRQn);
NVIC_ClearPendingIRQ(GPIO_EVEN_IRQn);
NVIC_EnableIRQ(GPIO_EVEN_IRQn);

GPIO_IntEnable( 1<<KEY_PIN | 1<<KEY2_PIN);
}
void GPIO_EVEN_IRQHandler(void)
{
SEGGER_RTT_printf("key1 pressed ****\r\n");

GPIO_IntClear(1<<KEY2_PIN);
}
void GPIO_ODD_IRQHandler(void)
{
SEGGER_RTT_printf("key2 pressed ####\r\n");

GPIO_IntClear(1<<KEY_PIN);
}

int main(void)
{
CHIP_Init();
GPIO_Init();
while(1)
{
SEGGER_RTT_printf("****** GO Sleep ******\r\n");
EMU_EnterEM2(false);
SEGGER_RTT_printf("****** Wake Up ******\r\n");
}
}

Posts: 2,810
Registered: ‎02-07-2002

Re: PB13 cannot wakeup from EM2 on EFM32ZG110

Editing your own posts is a privilege you need to earn. Click on your current 'star' ranking for more info.

Posts: 490
Registered: ‎02-04-2013

Re: PB13 cannot wakeup from EM2 on EFM32ZG110

This code works fine on the ZG STK with a ZG222.

 

I just had to add GPIO clock enable at the start of GPIO_Init():

 

CMU_ClockEnable(cmuClock_GPIO, true);

 

I didn't use the SEGGER_RTT_printf() functions since I'm not familiar with them.  I just set/clear the on-board LEDs when either of these interrupts fire.

 

Are these blocking printf?  If not, the part may go to sleep before the messages are completely transmitted.  Where are these defined and how do they work?

 

Are you sure you're not using some intrusive debug logging like semihosting?  What compiler/IDE are you using?  A lot of debug printf code doesn't work in EM2.  Also, you'd have to reset the part to get it to actually enter EM2 after using any kind of debugger.  With debug attached, the part can only go down to EM1.

 

My guess is there's a problem with this function working in EM2 or you have a conflict on PB13.  Note that this is shared with HFXTAL_P and LEU0_TX #1, so make sure you're not using either of these two peripherals/pins.

 

Best regards,

Chris

Highlighted
Posts: 235
Registered: ‎11-17-2013

Re: PB13 cannot wakeup from EM2 on EFM32ZG110

The SEGGER Stuff won't work properly in interrupt context. It tries to use BASEPRI to lock interrupts, but that won't work with interrupts in the default priority zero level AFAIK.

 

Raising the interrupt priority with NVIC_SetPriority() may help here, see definition of SEGGER_RTT_MAX_INTERRUPT_PRIORITY in SEGGER_RTT_Conf.h header file.

Posts: 3
Registered: ‎03-16-2017

Re: PB13 cannot wakeup from EM2 on EFM32ZG110

hello, finally I had found the root cause.

I did try to build a new project, and it run well as yours. but the old one with same code just keep sleep on PB13.

I compared everything, and found this Preprocessor Symbols Define is different...(as in the picture) 

after I changed EFM32ZG110F32 _EFM32_GECKO_FAMILY 

to EFM32ZG110F32   or   nothing, the problem disappeared.