Hi , I want to trigger the wakeup event after button keep pressed 2 seconds, can I test it at idle or active mode first?
the process of my code as belows,
user_app_init
-->wkup_button_enable
----->wkupct_register_callback(wkup_button_cb);
wkupct_enable_irq(WKUPCT_PIN_SELECT(WKUP_BUTTON_PORT, WKUP_BUTTON_PIN),
WKUPCT_PIN_POLARITY(WKUP_BUTTON_PORT, WKUP_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW),
40,
50);
static void wkup_button_cb(void)
{
if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
{
periph_init();
}
GPIO_ConfigurePin(GPIO_LED_PORT, GPIO_LED_PIN, OUTPUT, PID_GPIO, false);
app_easy_timer(1, led_blink_timer_cb_handler);
}
static void led_blink_timer_cb_handler()
{
static uint8_t idx = 0;
if(GPIO_GetPinStatus(GPIO_LED_PORT, GPIO_LED_PIN)){
GPIO_SetInactive(GPIO_LED_PORT, GPIO_LED_PIN);
}else{
GPIO_SetActive(GPIO_LED_PORT, GPIO_LED_PIN);
}
if(idx < 10){
idx += 1;
app_easy_timer(100, led_blink_timer_cb_handler);
}else{
idx = 0;
GPIO_ConfigurePin(GPIO_LED_PORT, GPIO_LED_PIN, INPUT_PULLDOWN, PID_GPIO, false);
}
}
Hi Andrew886,
The WKUP controller is always powered on, so you could use either active or sleep mode in order to detect the interrupt. Normally, the WKUP controller is been using for waking up from sleep mode. Please check the ble_app_sleepmode example of the SDK for getting more information. Regarding the wkupct_enable_irq() the events_num is the number of events before wakeup interrupt, so you need to set it to 1. Also, the maximum allowed debouncing time is 0x3F. Could you please let me know which project of the SDK you are using and which are your issues?
Thanks, PM_Dialog
Hi PM_Dialog,
I used ble_app_peripheral project(SDK 5.0.4 of DA14580) to develop my application, and I refer to ble_app_sleepmode project, too.
I want to wake up chip from deep sleep mode by press a button 2 seconds long. Since the chip can enter deep sleep mode only when OTP programmed. So I want to test the software at active mode or extend sleep mode as most as it can be.
My 1st issue: is there convenient method to test deep sleep mode? If I burn hex file to OTP and can not work well, then I can not to test deep sleep mode at the same chip/board again.
2nd issue:
I can use to below code to trigger wakeup interrup. if I comment the GPIO_SetPinFunction, it doesn't work. why?
As I understand, at deep sleep mode, periphral is power down. GPIO_SetPinFunction needn't to execute.
static void wkup_button_cb(void)
{
lowlevel_hold_timer_cb_h app_easy_timer (1andler);
//wkupct_register_callback(wkup_button_cb);
wkupct_enable_irq(WKUPCT_PIN_SELECT(WKUP_BUTTON_PORT, WKUP_BUTTON_PIN),\
WKUPCT_PIN_POLARITY(WKUP_BUTTON_PORT, WKUP_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW),\
1,\
40);
}
void wkup_button_enable(void)
{
GPIO_SetPinFunction(WKUP_BUTTON_PORT, WKUP_BUTTON_PIN, INPUT_PULLUP, PID_GPIO);
wkupct_register_callback(wkup_button_cb);
wkupct_enable_irq(WKUPCT_PIN_SELECT(WKUP_BUTTON_PORT, WKUP_BUTTON_PIN),
WKUPCT_PIN_POLARITY(WKUP_BUTTON_PORT, WKUP_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW),
1, // 1 event
40);
}
Hi Andrew886,
Issue #1: Please check the CFG_DEVELOPMENT_DEBUG macro in da1458x_config_basic.h file. This macro enables the development/debug mode. For production mode builds it must be disabled. When enabled, the SysRAM is not powered down in deep sleep mode. So, the developer is allowed to run applications using Deep Sleep mode without programming OTP memory. Please read the comments that macro.
Issue #2: Could you please indicate if you have the WKUP GPIO reserved and configured in user_periph_setup.c file? You should not call the GPIO_SetPinFunction() in the wkup_button_enable. Please check how the GPIO_BUTTON is defined and configured in user_periph_setup.c / .h files of ble_app_sleepmode example of the SDK.
If you found any answer useful, please mark one of them as “accepted”.
Thanks, PM_Dialog