延长睡眠从UART醒来

Learn More常见问题解答教程

9 posts / 0 new
最后一篇
Hamiddhosseini
离线
最后一次露面:3 months 2 weeks ago
加入:2020-05-12 12:04
延长睡眠从UART醒来

亲爱的对话支持团队,

I have successfuly integrated theuartSDK的示例ble_app_peripheral。我有能力在具有BLE功能时发送和接收数据。

但是,当UART不忙节省电量时,我试图将我的电路板放入扩展的睡眠模式。换句话说,两件事应该能够在扩展睡眠模式下唤醒板:

1-BLE定时器发送广告数据包。

2-UART RX PIN.

I understand that the following steps should be taken for this purpose:

1-Right before going to sleep I have to disable the uart and set the Rx pin to be used for waking up the board.

2-从此引脚唤醒时,我应该激活UART并开始收听消息。(我明白我可能会失去一些数据!)

I'm a bit lost about how to properly configure the extended sleep mode and seting the callbacks. could you please provide me with some instructions in this regard? (Due to hardware limitations, I can't use UART in 4-wire mode, therefore; I'm trying to use the sam Rx pin for both purposes.)

Regards,

汉米德

Device:
PM_DIALOG.
离线
最后一次露面:15 hours 6 min ago
职员
加入:2018-02-08 11:03
嗨哈米德,

嗨哈米德,

谢谢你的问题。我建议首先检查我们的睡眠模式从DA14531产品页面 - 对于您的方便链接提供如下:

http://lpccs-docs.dialog-semondile.com/da14531_sleep_mode+/index.html.

Additionally, the ble_app_sleepmode example of the SDK configured the DA14531 in permanent sleep mode. In order to wake it up, you should use the WAKEUP controller. Please check app_button_enable() function.

谢谢,PM_DIALOG.

Hamiddhosseini
离线
最后一次露面:3 months 2 weeks ago
加入:2020-05-12 12:04
你好,

你好,

Thanks for your response.

I've read through the tutorial but I can't find my answers.

Is is possible to useapp_easy_timer.during extended sleep mode? In other words, can this timer wake up the board from extended sleep? THat being said, the board would be sleeping unless it needs to wake up for sending an advertisement packet or while uart is busy.

Regards,

汉米德

PM_DIALOG.
离线
最后一次露面:15 hours 6 min ago
职员
加入:2018-02-08 11:03
嗨哈米德,

嗨哈米德,

Sorry, probably I misunderstood your question. Yes, you can use app_easy_timer(0 in order to wakeup periodically, as this API is used the BLE timer, so it can be used in sleep mode.

Let's assume that you want to wake up and start advertising . This can be achieved by setting the timer as shown here:

app_easy_timer(100,cb_my_timeout);

第一个参数指定在100 * 10 ms = 100ms = 1s后的超时计时器。此时回调CB_MY_Timerout()调用。

谢谢,PM_DIALOG.

Hamiddhosseini
离线
最后一次露面:3 months 2 weeks ago
加入:2020-05-12 12:04
你好,

你好,

Thanks a lot.That clarified some parts of this problem for me. I have another question which I'm doubtfull about:

我想使用UART_RX_PIN.醒来以及计时器。更清晰,我想必须唤醒方式(定时器和提到的PIN)。

据我所知,在醒来的回调中我需要

  • disable the wake up interrupts
  • 再次初始化此引脚上的UART

然后我可以开始receiving data。之后我必须

  • 禁用UART.
  • enable the wake up interrupts

返回正常运行。

Am I correct? Is it possible to change the use of a pin during operation like this?

Regards,

汉米德

PM_DIALOG.
离线
最后一次露面:15 hours 6 min ago
职员
加入:2018-02-08 11:03
嗨哈米德,

嗨哈米德,

如果您想通过GPIO触发(UART RX)唤醒(UART RX),则应配置唤醒控制器并寄存该引脚。在SDK的BLE_APP_SLEEPMODE示例中,可以通过GPIO_BUTTON_PORT / _PIN唤醒设备。请检查wkupct_enable_irq()。在您的情况下,您应该使用UART RX引脚配置它。

请记住,当系统是睡眠模式时,所有包括UART的外围域都会关闭,因此当芯片睡眠时,它不可能具有UART活动。这意味着您将错过将第一个字符捕获到UART RX PIN才能唤醒它。

谢谢,PM_DIALOG.

Hamiddhosseini
离线
最后一次露面:3 months 2 weeks ago
加入:2020-05-12 12:04
到目前为止我已经完成了

到目前为止我已经完成了以下事情:

  • Defining the pin and port for the wakeup same as the ones I'm using for UART2 Rx.
  • 定义函数禁用UART并使唤醒引脚允许如下:
    void wkup_periph_init(){ //Stop the uart uart_disable(UART2); //Set the wakeup pin GPIO_ConfigurePin(EXT_WKUP_GPIO_PORT, EXT_WKUP_GPIO_PIN, INPUT_PULLUP, PID_GPIO, false); }
  • 改变这一点gpio_reservations()andset_pad_functions()
void gpio_reservations(void){/ * i.et.保留p0_1作为通用目的I / O:letail_gpio(descriptionive_name,gpio_port_0,gpio_pin_1,pid_gpio);* / #f定义(cfg_printf_uart2)letaent_gpio(uart2_tx,uart2_tx_port,uart2_tx_pin,pid_uart2_tx);#Endif Letail_GPIO(UART2_RX,UART2_RX_PORT,UART2_RX_PIN,PID_UART2_RX);//保留_gpio(Push_Button,GPIO_Button_Port,GPIO_Button_pin,PID_GPIO);#if!定义(__da14586__)保留_gpio(spi_en,spi_en_port,spi_en_pin,pid_spi_en);#endif} #endif void set_pad_functions(void){/ * i.e.将p0_1设置为通用用途输出:gpio_configurepin(gpio_port_0,gpio_pin_1,输出,pid_gpio,false);* / #f定义(__da14586__)//禁止自发da14586 spi flash唤醒gpio_configurepin(gpio_port_2,gpio_pin_3,输出,pid_gpio,true);#else //禁止自发spi flash唤醒gpio_configurepin(spi_en_port,spi_en_pin,输出,pid_spi_en,true);#endif gpio_configurepin(ext_wkup_gpio_port,ext_wkup_gpio_pin,input_pullup,pid_gpio,false);#f定义(cfg_printf_uart2)//配置UART2 TX PAD GPIO_CONFIGUREPIN(UART2_TX_PORT,UART2_TX_PIN,OUTPUT,PID_UART2_TX,FALSE); #endif }
  • 添加以下行user_app_adv_start():
//在广告arch_set_extended_sleep(false)期间,在没有OTP副本的情况下设置延长睡眠;ARCH_BLE_EXT_WAKEUP_ON();//配置WakeUp PIN WKUP_PERIPH_INIT();app_wkup_pin_enable();
  • 从UART_BLE_SLEEPMODE修改回调函数示例:
/** **************************************************************************************** * @brief Button press callback function. Registered in WKUPCT driver. **************************************************************************************** */ static void app_uart_trigered_cb(void) { #if !defined (__DA14531__) if (GetBits16(SYS_STAT_REG, PER_IS_DOWN)) #endif { periph_init(); } //I want to set the Rx and Tx pins to receive over uart uart_startup_proccess(UART2); if (arch_ble_ext_wakeup_get()) { arch_set_sleep_mode(app_default_sleep_mode); arch_ble_force_wakeup(); arch_ble_ext_wakeup_off(); app_easy_wakeup(); } } /** **************************************************************************************** * @brief Application wakeup callback function. Registered in API message utility. **************************************************************************************** */ static void app_wakeup_cb(void) { uart_receive_intr_init(UART2); } /** **************************************************************************************** * @brief Sets UART as wakeup trigger **************************************************************************************** */ void app_wkup_pin_enable(void) { app_easy_wakeup_set(app_wakeup_cb); wkupct_register_callback(app_uart_trigered_cb); wkupct_enable_irq(WKUPCT_PIN_SELECT(EXT_WKUP_GPIO_PORT, EXT_WKUP_GPIO_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN) WKUPCT_PIN_POLARITY(EXT_WKUP_GPIO_PORT, EXT_WKUP_GPIO_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low 1, // 1 event 40); // debouncing time = 0 } void user_app_disable_button(void) { wkupct_disable_irq(); } void uart_startup_proccess(uart_t *uart){ //disabling the wkup interrupts user_app_disable_button(); //initializing the uart uart_periph_init(uart); uart_register_rx_cb(uart, uart_receive_intr_cb); }

但是,当我在调试模式下运行代码时,在接收到唤醒引脚上的新字节时没有更改,并且设备保持广告。你能给我一些关于这个问题可能原因的建议吗?

Regards,

汉米德

Hamiddhosseini
离线
最后一次露面:3 months 2 weeks ago
加入:2020-05-12 12:04
你好,

你好,

我想表明我已经成功实现了我所需的架构。谢谢你的时间。

Regards,

汉米德

PM_DIALOG.
离线
最后一次露面:15 hours 6 min ago
职员
加入:2018-02-08 11:03
嗨哈米德,

嗨哈米德,

高兴你和感谢佛求了你的问题r let us know. According to the app_wkup_pin_enable(), a low pulse signal should trigger the wake-up controller.

如果您有任何其他问题,请提出一个新的论坛线程。

谢谢,PM_DIALOG.