cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L072CZ/B-L072Z-LRWAN1 wakeup from external interrupt

Anton Anton_2
Associate
Posted on March 23, 2018 at 20:00

Hi,

I've made a custom board based on

CMWX1ZZABZ-091 which contains theSTM32L072CZ device and am currently trying to modify existing End_Node (\STM32CubeExpansion_LRWAN_V1.1.4\Projects\Multi\Applications\LoRa\End_Node) application to transmitt data on two events: either a timer event or external gpio event. While looking at the source code I see that the following functions exists:

LoraStartTx( TX_ON_TIMER) ;�?

Which basically selects one(!)event that will wake-up the device from sleep in order to transmitt the data. Is it possible to have two wakeup sources ? If yes, is it as simple as to modify the LoraStartTx function as follows:

static void LoraStartTx(void)
{
 /* send everytime timer elapses */
 TimerInit( &TxTimer, OnTxTimerEvent );
 TimerSetValue( &TxTimer, APP_TX_DUTYCYCLE); 
 OnTxTimerEvent();
 /* send everytime button is pressed */
 GPIO_InitTypeDef initStruct={0};
 
 initStruct.Mode =GPIO_MODE_IT_RISING;
 initStruct.Pull = GPIO_PULLUP;
 initStruct.Speed = GPIO_SPEED_HIGH;
 
 HW_GPIO_Init( USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, &initStruct );
 HW_GPIO_SetIrq( USER_BUTTON_GPIO_PORT, USER_BUTTON_PIN, 0, Send );
 
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

In my design the USER_BUTTON_PIN is routed to a different location, I'm using PA0, so the HW_GPIO_SetIrq function manages to register interrupt callback function within the GpioIrq table (hw_gpio.c), but somehow my entry gets overwritten by the semtechinternal calls to HW_GPIO_SetIrq. What are my options here?

The reason for choosing the PA0 is it's ability to wake the device up from any sleep mode, as it's designated as WKUP, I've tried to configure it as wakeup with the following piece of code:

HAL_PWR_EnableWakeUpPin (PWR_WAKEUP_PIN1);�?

During initialization, but that didn't seem to work. Is there any additional configuration that needs to be done? Do I need that wakeup pin at all or can any exti interrupt be used for waking the device up from any sleep mode?

So to summarize my questions:

1. How to configure the device to wakeup on either a timer event or external gpio interrupt?

2. What to do with limited functionality of hw_gpio.h/c implementations.

3. How can PA0 wakeup functionality be used in the End_Node application.

Best Regards,

Anton

#stm32l072cz #b-l072z-lrwan1 #cmwx1zzabz-09
4 REPLIES 4
T J
Lead
Posted on March 25, 2018 at 15:13

I don't know your answers, but answering here will promote your question.

did you pull up the input pin ?

did you configure the alternate function to WakeUp ?

did you check the reference manual ?

Anton Anton_2
Associate
Posted on March 27, 2018 at 11:43

Hi TJ, thanks for responding

did you pull up the input pin ?

According to hal source code, wakeup pin is automatically forced to pull-down. 

did you configure the alternate function to WakeUp ?

There is no AF mapping for wakeup pin in the stm32l0xx_hal_gpio_ex.h file so i believe that configuring that pin as an input with pull-down and enbaling wakeup via HAL_PWR_... is sufficient.

did you check the reference manual ?

Didn't find much info there, most of the information was gathered via the header files of the peripheral library.

Gaurav Bansal
Associate
Posted on May 23, 2018 at 04:05

Hi, Anton!

Did you find a solution to this?

I am also stuck in a somewhat similar situation as described here.

Thanks.

jibi jibi
Associate
Posted on June 21, 2018 at 13:27

Hi,

For me, you can't use the pin A0 (WKUP1) as interrupt, because the pin B0 (DIO2) is connected to the SX1276 and

this pin is programmed as interrupt

.

The interruption can be programmed only for one pin.

Look the registre 'SYSCFG_EXTICR1' in the datasheet

Best regards.