DSPS use GPIO control into its extended sleep and wake up.

13 posts / 0 new
Last post
Lane
Offline
Last seen:1个月6天前
Joined:2015-07-14 14:21
DSPS use GPIO control into its extended sleep and wake up.

Hi Dialog

There are some problem that I was use the DSPS 3.150.2 device project to Data transmission.The da4580_config.h was set to :
#define CFG_EXT_SLEEP
#undef cfg_deep_sleep.
but ,when I was Connection with my peer divce ,it also Into sleep mode and Data transmission will be lost,so I want to know How to set a GPIO wake-up To ensure that the DA did not enter sleep .I was set by According 《AN-B-026 DA14580 External wake-up mechanisms》 to configure:

#define EXTERNAL_WAKEUP 1
......
ext_wakeup_enable(uart1_ctsn_gpio_port,uart1_ctsn_gpio_pin,1);
......
is that any Other settings I have modified to wake The DA up by GPIO.

TKS

关键词:
Device:
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi Lane,

Hi Lane,

In order for you to check how to enable the external wakeup mechanism and how to register a callback function please have a look at the smart tag reference design in the app_button_press_cb() function. Also please have a look at the document UM-B-051 at section 10.7 Wakeup Timer.

Thanks MT_dialog

Lane
Offline
Last seen:1个月6天前
Joined:2015-07-14 14:21
Hi Dialog,

Hi Dialog,
已阅读文档UM-B-051中的10.7节,并将程序设置为它。但DA14580仍然在睡眠状态
That is my code before the DA go to sleep:
app_set_extended_sleep();
app_ble_ext_wakeup_on();
ext_wakeup_enable(UART1_CTS_PORT, UART1_CTS_PIN, 1);
scb-> scr | = 1 << 2;//在系统控制寄存器中启用睡眠模式位(SCR [2] = SleepDeep)
SetBits16(Sys_ctrl_reg,pad_latch_en,1);//激活焊盘锁存器
SetBits16(PMU_CTRL_REG, RADIO_SLEEP, 1); // turn off radio
SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); // turn off peripheral power domain
SetBits16(SYS_CTRL_REG, RET_SYSRAM, 1); // turn System RAM off => all data will lost
函数“ext_wakeup_enable()”:
void ext_wakeup_enable(uint32_t port, uint32_t pin, uint8_t polarity)
{
rwip_env.ext_wakeup_enable = 2;
#if DEVELOPMENT_DEBUG
RESERVE_GPIO( EXT_WAKEUP_GPIO, (GPIO_PORT) port, (GPIO_PIN) pin, PID_GPIO );
#endif
RESERVE_GPIO( EXT_WAKEUP_GPIO, (GPIO_PORT) port, (GPIO_PIN) pin, PID_GPIO );
if ( polarity == 0 ) // active low
GPIO_ConfigurePin((GPIO_PORT) port, (GPIO_PIN) pin, INPUT_PULLUP, PID_GPIO, false ); // active low. Set default to input high.
否则//主动高
GPIO_ConfigurePin ((GPIO_PORT)端口(GPIO_PIN)πn, INPUT_PULLDOWN, PID_GPIO, false ); // active high. Set default to input low.

wkupct_register_callback(ext_wakeup_cb);

wkupct_enable_irq(1<

Lane
Offline
Last seen:1个月6天前
Joined:2015-07-14 14:21
(No subject)
MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi Lane,

Hi Lane,

Please follow the example in the Smart Tag reference design in order to wake up, check the app_button_press_cb() function (wakes up the da from a button). You can check if the configuration is ok by using a button to wake it up and then implement the CTS wake up.

Thanks MT_dialog

Lane
Offline
Last seen:1个月6天前
Joined:2015-07-14 14:21
非常感谢,我有

非常感谢,我有found problem,It has been resolved .as follow :
in function “wkupct_enable_irq()” is say that:@param[in] sel_pins Select enabled inputs. Bits 0-7 -> port 0(P00..P07), Bits 8-13 -> port 1(P10..P15), Bits 14-15 -> port 2(P28,P29), Bits -> 16-23 port 2(P00..P07), Bits 24-31 -> port 3(P30..P37). 0-disabled, 1-enabled.
I use the P2_3 Port to wake up ,but in the function “ext_wakeup_enable()”,the line is wkupct_enable_irq(1<

CD
Offline
Last seen:3 years 10 months ago
Joined:2015-11-18 02:51
Thanks Lane and MT_dialog,

Thanks Lane and MT_dialog,

I just met the same problem. Lane should be right. Following function in the SDK 5.0.3 (and also SDK 3.x.x) seems to have a problem...


void ext_wakeup_enable(uint32_t port, uint32_t pin, uint8_t polarity)
{
rwip_env.ext_wakeup_enable = 2;
#if DEVELOPMENT_DEBUG
RESERVE_GPIO( EXT_WAKEUP_GPIO, (GPIO_PORT) port, (GPIO_PIN) pin, PID_GPIO );
#endif
if ( polarity == 0 ) // active low
GPIO_ConfigurePin((GPIO_PORT) port, (GPIO_PIN) pin, INPUT_PULLUP, PID_GPIO, false ); // active low. Set default to input high.
否则//主动高
GPIO_ConfigurePin ((GPIO_PORT)端口(GPIO_PIN)πn, INPUT_PULLDOWN, PID_GPIO, false ); // active high. Set default to input low.

wkupct_register_callback(ext_wakeup_cb);

wkupct_enable_irq(1 << PIN,(UINT32_T)(极性== 0)?(1 << PIN):( 0),1,0);// PIN,有效低/高,1个事件,DEBOUNCING TIME = 0ms
}

If we call this function like:
ext_wakeup_enable( GPIO_PORT_2, GPIO_PIN_3, 0)
this method callswkupct_enable_irq()function withwrong parametersin the end.
wkupct_enable_irq()函数需要以下参数:

/ **
****************************************************************************************
* @brief Enable Wakeup IRQ.
*
* @param[in] sel_pins Select enabled inputs. Bits 0-7 -> port 0(Port 00..P07), Bits 8-13 -> port 1(P10..P15), Bits 14-15 -> port 2(P28,P29), Bits -> 16-23 port 2(Port 00..P07), Bits 24-31 -> port 3(P30..P37). 0-disabled, 1-enabled.
* @param[in] pol_pins Inputs' polarity. Bits 0-7 -> port 0(Port 00..P07), Bits 8-13 -> port 1(P10..P15), Bits 14-15 -> port 2(P28,P29), Bits -> 16-23 port 2(Port 00..P07), Bits 24-31 -> port 3(P30..P37). 0-high, 1-low.
* @param[in] events_num Number of events before wakeup interrupt. Max 255.
* @param[in] deb_time Debouncing time. Max 0x3F.
*
* @return void
****************************************************************************************
*/
void wkupct_enable_irq(uint32_t sel_pins, uint32_t pol_pins, uint16_t events_num, uint16_t deb_time)

If there are good solution to solve this, please let me know.

感谢您提前支持。

此致,
CD

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi CD,

Hi CD,

ext_wakeup_enable是一个应该只使用完整的嵌入式设计时使用的函数,但这种实现不是由于您尝试使用它的原因。对于使用唤醒控制器,请使用唤醒驱动程序的API实现。您可以在参考设计中找到类似于ext_wakeup_enable的实现的示例。

Thanks MT_dialog

CD
Offline
Last seen:3 years 10 months ago
Joined:2015-11-18 02:51
Hi MT_dialog,

Hi MT_dialog,

Thanks for your quick reply.

Sorry, I'm getting confused... Please let me confirm the things there....

1.我的环境:我想使用DA14583作为完整的嵌入式设计。
2. Your comment is:

ext_wakeup_enable是一个应该只使用完整的嵌入式设计时使用的函数,但这种实现不是由于您尝试使用它的原因。

Can I use ext_wakeup_enable() function for the full embedded design system? Or do you want to mean ext_wakeup_enable() function should be used with "external processor running host application"?
在源代码中,有一些关于这些东西的评论,但它真的很困惑......

- da1458x_config_advanced.h -
线
64 /***************************************************/
65 /* Wakeup fromexternal processor running host application.*/
66 /***************************************************/
67 #undef CFG_EXTERNAL_WAKEUP

- arch.h -
线
210 #if defined(CFG_EXTERNAL_WAKEUP)
211 #define EXTERNAL_WAKEUP 1
212 #else
213 #define EXTERNAL_WAKEUP 0
214 #endif
.....
388 #if ((EXTERNAL_WAKEUP) && (!BLE_APP_PRESENT)) // external wake up, only in全嵌入式designs
389 void ext_wakeup_enable(uint32_t端口,uint32_t引脚,uint8_t极性);
390 void ext_wakeup_disable(void);
391年空白ext_wakeup_cb(无效);
392 #endif

- arch_main.c -
static inline void arch_goto_sleep (sleep_mode_t current_sleep_mode)
{
sleep_mode_t sleep_mode = current_sleep_mode;
ble_turn_radio_off();
//turn the radio off and check if we can go into deep sleep
sleep_mode = ble_validate_sleep_mode(sleep_mode);
// grant access to the application to check if we can go to sleep
app_sleep_prepare_proc(&sleep_mode); //SDK Improvements for uniformity this one should be changed?
//turn the peripherals off according to the current sleep mode
arch_turn_peripherals_off(sleep_mode);
#if (USE_POWER_OPTIMIZATIONS)
fine_hit = false;
#endif
//睡觉前的应用程序特定任务
app_sleep_entry_proc(sleep_mode);
#if ((EXTERNAL_WAKEUP) && (!BLE_APP_PRESENT)) // external wake up, only inexternal processordesigns
ext_wakeup_enable(GPIO_PORT_2, GPIO_PIN_2, 0);
#endif
// do the last house keeping of the clocks and go to sleep
arch_switch_clock_goto_sleep (sleep_mode);
}

- ARCH_SYSTEM.C -
#if ((EXTERNAL_WAKEUP) && (!BLE_APP_PRESENT)) // only in全嵌入式designs
/ **
****************************************************************************************
* @brief启用外部唤醒GPIO中断。
* @param[in] GPIO_PORT. The GPIO port of the external wake up signal
* @param[in] GPIO_PIN. The GPIO pin of the external wake up signal
* @param[in] polarity. The polarity of the external wake up interrupt. 0=active low. 1=active high
* @return void.
****************************************************************************************
*/
void ext_wakeup_enable(uint32_t port, uint32_t pin, uint8_t polarity)
{
rwip_env.ext_wakeup_enable = 2;
if (DEVELOPMENT_DEBUG)
RESERVE_GPIO( EXT_WAKEUP_GPIO, (GPIO_PORT) port, (GPIO_PIN) pin, PID_GPIO );
if ( polarity == 0 ) // active low
GPIO_ConfigurePin((GPIO_PORT) port, (GPIO_PIN) pin, INPUT_PULLUP, PID_GPIO, false ); // active low. Set default to input high.
否则//主动高
GPIO_ConfigurePin ((GPIO_PORT)端口(GPIO_PIN)πn, INPUT_PULLDOWN, PID_GPIO, false ); // active high. Set default to input low.
wkupct_register_callback(ext_wakeup_cb);
wkupct_enable_irq(1 << PIN,(UINT32_T)(极性== 0)?(1 << PIN):( 0),1,0);// PIN,有效低/高,1个事件,DEBOUNCING TIME = 0ms
}

As I listed up above, there are same #if statements "#if ((EXTERNAL_WAKEUP) && (!BLE_APP_PRESENT))", but the comments for those are mixed with full embedded and external processor per a file or a function.
If I used DA1458x as a full embedded design, I should code as followings, is it right??? :

#undefCFG_EXTERNAL_WAKEUP

Arch_goto_sleep()ext_wakeup_enable()在完整的嵌入式设计系统时未调用,不是吗?!是我的理解吗?!?
So, as you mentioned, we have to use wake up controller to wake up on full embedded design system. I believe the code for waking up would be something like followings:
1st: Register callback function when system wakes up: using wkupct_register_callback()
2nd:启用IRQ for WakeUp:WKUPCT_ENABLE_IRQ(0x40000,0x40000,1,0);// i.e.p2_2,p2_2的高电平为低电平,1个事件,debouncing time = 0ms
当我编写上面时,我的系统似乎醒来。(让我查看关于GPIO唤醒的对话框的一些示例项目。)

3. Even though ext_wakeup_enable() is desinged for only full embedded (or external processor host?) design, ext_wakeup_enable() function in arch_system.c seems wrong, as Lane mentioned too, I think.
ext_wakeup_enable() function needs 3 parameters, wakeup GPIO port, pin and polarity. So, if users want to wake up P2_2 with low active event, user call this like: ext_wakeup_enable(GPIO_PORT_2, GPIO_PIN_2, 0).
On the other hand, in ext_wakeup_enable() function, port information(i.e. GPIO_PORT_2) is completely lost. wkupct_enable_irq() function required bit expression to select port and pin including port information. Current code of ext_wakeup_enable() can a handle the signal change on only PORT_0. (In other words, ext_wakeup_enable(GPIO_PORT_2, GPIO_PIN_2, 0) will be modified to GPIO_PORT_0, GPIO_PIN_2 with low active event in ext_wakeup_enable() function.

Sorry for my long reply, but if you could provide any comments on this, it would be much appreciated.

Thanks for your great support.

此致,
CD

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi CD,

Hi CD,

Just some clarifications fully mbeded -> Application runs on external MCU, fully hosted -> application runs on DA

I haven't realised that you were using a fully embedded design (running from an external host), since you are, then yes you can use the function. The thing is that the code assumes that you are going to use only pins from port 0. This part must be corrected, and will be in future SDK versions. If you are going to use a fully embedded design and you run your application from an external host and you want your device to wake up from an external MCU then you have to configure the external wake up. The ext_wakeup_enable() is used in full embedded designs (since the application should wake up from the external proccessor). If your design was fully hosted then you should use the code you are mentioning.

Thanks MT_dialog

CD
Offline
Last seen:3 years 10 months ago
Joined:2015-11-18 02:51
Hi MT,

Hi MT,

Thank you very much for your comments.
Yes, you are right. I had mixed up "full embedded" with "fully hosted". I'm so sorry about this...

As you mentioned, we would like to use DA1458x as "fully hosted" design (using DA as an integrated processor).

So I have to code like followings, is it right?

#undefCFG_EXTERNAL_WAKEUP
系统唤醒时注册回调函数:使用wkupct_register_callback()
Enable IRQ for wakeup: wkupct_enable_irq(0x40000, 0x40000, 1, 0); // i.e. P2_2, active low for P2_2, 1 event, debouncing time = 0ms

再次感谢,
CD

MT_dialog
Offline
Last seen:2 months 3 weeks ago
Staff
Joined:2015-06-08 11:34
Hi CD,

Hi CD,

Yes, thats right, register your callback (wkupct_register_callback(your function)) and enable the pins and the polarity to the appropriate pin (wkupct_enable_irq()).

Thanks MT_dialog

CD
Offline
Last seen:3 years 10 months ago
Joined:2015-11-18 02:51
Hi MT,

Hi MT,

Thank you very much for your confirmation.
Now, it's clear!!

Thanks a lot,
CD

Topic locked