System stuck at wakeup and no other buttons are working

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
4 posts / 0 new
Last post
mahmed106
Offline
Last seen:1 month 5 days ago
Joined:2019-05-03 17:28
System stuck at wakeup and no other buttons are working

Hi dialog

I am working on a custom board based on DA14681. I am using two buttons on GPIOs to perform some tasks and they are working perfectly.

Then i m using a GPIO, which is directly connected to USB Power. When USB is connected this GPIO goes high and i do a specfic task which is also working perfectly.

Problem is that i am using hibernation mode and i am using This USB Power GPIO for wakeup purposes. When in hibernation mode as soon as i plug in the USB it wakesup and works perfectly but other two buttons stops functioning and then USB is removed then those two buttons start working again. I couldnt undertand this problem.

这是main.c中的代码

PM_SYSTEM_INIT(PERIPH_INIT);

hw_wkup_init(null);
hw_wkup_configure_pin(DIS_BUTTON_PORT,DIS_BUTTON_PIN, true, HW_WKUP_PIN_STATE_HIGH); // button 1
hw_wkup_configure_pin(PWR_BUTTON_PORT,PWR_BUTTON_PIN, true, HW_WKUP_PIN_STATE_HIGH); // button 2

hw_wkup_configure_pin(HW_GPIO_PORT_4, HW_GPIO_PIN_0, true, HW_WKUP_PIN_STATE_HIGH); // wakeup with USB-CONNECTION

hw_wkup_set_debounce_time(10);
hw_wkup_set_counter_threshold(1);
hw_wkup_register_interrupt(wkup_cb, 1);

Device:
PM_Dialog
Offline
Last seen:1 day 5 hours ago
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

请问您是否有PeripH_Init(函数)中配置的按钮?我假设你的设备通过电池供电,是正确的吗?

Thanks, PM_Dialog

mahmed106
Offline
Last seen:1 month 5 days ago
Joined:2019-05-03 17:28
Yes device is powered via

Yes device is powered via battery and this is my periph_init function, i have defined buttons but no defined usb connection gpio.

static void periph_init(void)
{
#if 1 //defined CONFIG_RETARGET
/*
* jlink仿真串口的解决方法。
*
* JLink serial port does not set its output UART pin high (UART idle state) unless
* there is something transmitted from PC to board.
* PIN状态按电平移位器保持后的电平移位器复位。
* Configuring pin as UART_RX does not turn on pull up resistor, hence RX line stays low
* and this state is usually detected as break condition.
* With low state on UART RX, configuration of UART is unsuccessful: as soon as baud rate
* is set up UART goes into busy state, all other settings are ignored.
*
* Workaround sets up pin that will be used as UART RX as output with high state.
* This will result in level shifter holding this state until JLink starts to drive this
* line for transmission.
*/

#if OLD_HARDWARE
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_0, HW_GPIO_MODE_OUTPUT,HW_GPIO_FUNC_UART_TX);
#else // same for dry and liquid
REG_SET_BIT (CRG_PER USBPAD_REG USBPAD_EN);
hw_gpio_set_pin_function(HW_GPIO_PORT_2, HW_GPIO_PIN_2, HW_GPIO_MODE_OUTPUT,HW_GPIO_FUNC_UART_TX);
#endif
// hw_gpio_set_pin_function(HW_GPIO_PORT_2, HW_GPIO_PIN_2, HW_GPIO_MODE_OUTPUT,
// hw_gpio_func_uart_rx);
#endif


hw_gpio_configure_pin(HW_GPIO_PORT_2,HW_GPIO_PIN_3, HW_GPIO_MODE_INPUT_PULLUP,HW_GPIO_FUNC_GPIO, 1);
//hw_gpio_configure_pin(HW_GPIO_PORT_2, HW_GPIO_PIN_3, HW_GPIO_MODE_OUTPUT,HW_GPIO_FUNC_GPIO, 1);
hw_gpio_set_pin_function(HW_GPIO_PORT_1, HW_GPIO_PIN_5,HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_UART2_TX);
hw_gpio_set_pin_function(HW_GPIO_PORT_2, HW_GPIO_PIN_3,HW_GPIO_MODE_INPUT_PULLUP, HW_GPIO_FUNC_UART2_RX);

hw_gpio_configure_pin(BUZZ_PORT, BUZZ_PIN, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, 0);
hw_gpio_configure_pin(THM_PWR_PORT, THM_PWR_PIN, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, 0);
// hw_gpio_configure_pin(pelt_port,pelt_pin,hw_gpio_mode_output,hw_gpio_func_gpio,0);
//hw_gpio_configure_pin(INFAN_PORT,INFAN_PIN, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, 0);
hw_gpio_configure_pin(TH1_PORT, TH1_PIN, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, 0);
hw_gpio_configure_pin(TH2_PORT, TH2_PIN, HW_GPIO_MODE_OUTPUT, HW_GPIO_FUNC_GPIO, 0);
hw_gpio_configure_pin(th3_port,th3_pin,hw_gpio_mode_output,hw_gpio_func_gpio,0);

hw_gpio_configure_pin(PWR_BUTTON_PORT,PWR_BUTTON_PIN, HW_GPIO_MODE_INPUT_PULLDOWN,HW_GPIO_FUNC_GPIO, 0);
hw_gpio_configure_pin(dis_button_port,dis_button_pin,hw_gpio_mode_input_pulldown,hw_gpio_func_gpio,0);

hw_gpio_configure_pin(HW_GPIO_PORT_3,HW_GPIO_PIN_7, HW_GPIO_MODE_OUTPUT,HW_GPIO_FUNC_GPIO, 1); // 3.3V Regulator

}

PM_Dialog
Offline
Last seen:1 day 5 hours ago
Staff
Joined:2018-02-08 11:03
Hi mahmed106,

Hi mahmed106,

It’s little bit strange because as soon as the device wakes up from hibernation, it like a cold boot and the periph_init() with your configurations will be executed. Can you please try to use a logic analyzer and track the GPIOs which are connected with the buttons in order to understand if it is a hardware or a software related issue?

Thanks, PM_Dialog