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

13 posts / 0 new
Last post
Lane
Offline
Last seen:4 weeks 1 day ago
加入: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
#深度睡眠
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\ U wakeup\启用(UART1\ U CTSN\ U GPIO\端口,UART1\ U CTSN\ U GPIO\引脚,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 2 weeks ago
Staff
加入: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:4 weeks 1 day ago
加入: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;//在系统控制寄存器中启用sleepdeph模式位(SCR[2]=sleepdeph)
SetBits16(系统控制寄存器,键盘闩锁,1);//激活PAD闩锁
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\u wakeup\u 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.
else//高电平
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:4 weeks 1 day ago
加入:2015-07-14 14:21
(No subject)
MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入: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:4 weeks 1 day ago
加入: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
加入: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.
else//高电平
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<}

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 \u enable \u 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 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi CD,

Hi CD,

ext\u wakeup\u enable是一个只应用于完全嵌入式设计的函数,此实现不是您尝试使用它的原因。要使用唤醒控制器,请使用唤醒驱动程序的API实现。您可以在参考设计中找到与ext\u wakeup\u enable的实现类似的示例。

Thanks MT_dialog

CD
Offline
Last seen:3 years 10 months ago
加入: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:

The ext_wakeup_enable is a function that should be used only with full embedded designs, this implementation isn't for the reason you are trying to use it.

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\u wakeup\u enable(uint32\u t端口、uint32\u t引脚、uint8\u t极性);
390 void ext\u wakeup\u disable(无效);
391年空白ext_wakeup_cb(无效);
392 #endif

- arch_main.c -
static inline void arch_goto_sleep (sleep_mode_t current_sleep_mode)
{
sleep\u mode\u t sleep\u mode=当前睡眠模式;
把收音机关掉();
//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);
#如果(USE_POWER_OPTIMIZATIONS)
fine\u hit=假;
#endif
//在睡觉前挂接特定于应用程序的任务
应用程序\睡眠\进入\程序(睡眠\模式);
#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);
}

-拱门系统-
#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.
else//高电平
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<}

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\u goto\u sleep()函数中的ext\u wakeup\u 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()
第二:为唤醒启用IRQ:wkupct_Enable_IRQ(0x40000,0x40000,1,0);//i、 e.P2琰2,P2琰2的低电平有效,1个事件,去抖动时间=0毫秒
当我在上面编码时,我的系统似乎醒了过来让我检查一下对话框中关于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 2 weeks ago
Staff
加入: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
加入: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\u register\u 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 2 weeks ago
Staff
加入: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
加入: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