DPSP数据丢失的睡眠ode

12 posts / 0 new
Last post
YuanhangWu
Offline
Last seen:4 years 11 months ago
Expert
加入:2015-03-25 08:19
DPSP数据丢失的睡眠ode

大家好。

In DSPS project,I have two work mode.
One is:
sps mode:
用手机发送和接收数据。
Other is:
configuration mode:
set configure parameter like connect parameter ,open advertising,close advertising,and so and.

Now,in dsps project "DA14580_DSPS_3.150.2" ,perpheral device.
BLE Link pc with uart.

My setup is follow:
#define CFG_LP_CLK 0xAA //no 32.768k crystal ,so set 0XAA
#define CFG_UART_HW_FLOW_CTRL
#define CFG_EXT_SLEEP

void set_pad_functions(void) // set gpio port function mode
{
GPIO_ConfigurePin( UART1_TX_PORT, UART1_TX_PIN, OUTPUT, PID_UART1_TX, false );
GPIO_ConfigurePin( UART1_RX_PORT, UART1_RX_PIN, INPUT_PULLUP, PID_UART1_RX, false );
#if (UART_HW_FLOW_ENABLED)
GPIO_CONFIGUREPIN(UART1_RTS_PORT,UART1_RTS_PIN,OUTPUT,PID_UART1_RTSN,FALSE);
GPIO_ConfigurePin( UART1_CTS_PORT, UART1_CTS_PIN, INPUT_PULLUP, PID_UART1_CTSN, false );
#endif /*UART_HW_FLOW_ENABLED*/
// gpio_configurepin(gpio_button_port,gpio_button_pin,input_pulldown,pid_gpio,false);
}

PC UART <----- FLOW1 ----> BLE UART <----- FLOW2 ------>手机。
我要做的是:
first step:
judge Flow1 is right or not.
In BLE UART ,I get data from pc,then i judge the flow data is right and then send a tips back to pc by uart.

if right,send
uart_write("\r\nOK\r\n", 6, NULL);
if not right,send
uart_write("\r\nEER\r\n", 7, NULL);

So ,in configuration mode, I used pc to send only one configuration command to BLE every second,but the tips is not every second back to pc.

我认为原因是睡眠和流量控制,因为当我的时候
send
close sleep and close flow control,the data is response Immediate.
and the tips is every second back to pc with the same
I want response Immediate,and open sleep and open flow control.
How to do to solve this problem?

请给我帮助。
thanks.

Keywords:
Device:
MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi YuanhangWu,

Hi YuanhangWu,

Can you please add the below code snippet and try again. Place this in the app_sleep_check function in the DSPS project:

else

{

// check UART. If a Tx or Rx Proceess is in progress disable sleep

if (uart_sps_fifo_check())

app_disable_sleep();

else

{

app_sleep_prepare(&sleep_mode);

if (sleep_mode == mode_sleeping)

app_set_extended_sleep();

else

app_disable_sleep();

Thanks MT_dialog

summer20100514
Offline
Last seen:4年5个月前
格鲁鲁
加入:2014-12-30 05:01
Hi, I placed the code snippet

嗨,我将代码段放在app_sleep_check函数中,但数据也丢失了。But when I disable the extended sleep mode, all data is received correctly. Could you please help me find the reason ? Thank you.

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi summer20100514,

Hi summer20100514,

Please have a look at the DSPS on the SDK 5, and check if you are loosing data there as well. The new version is quite tested so i dont think that you will have any issues.

Thanks MT_dialog

summer20100514
Offline
Last seen:4年5个月前
格鲁鲁
加入:2014-12-30 05:01
I have tested the dsps

I have tested the dsps project both sdk3 and sdk5. But, the result is always the same. When I enable the extended sleep mode, there will be data lose and junk data.

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi summer20100514,

Hi summer20100514,

我想你正在使用外部MCU而不是PC(你能用PC和Android或IOS应用程序还是PC2PC连接,并检查结果是否相同),你的流量控制是什么?您在系统中使用的设置,您也可以给我一些关于您的设置的信息吗?此外,在使用SW流量控制时,使用延长睡眠时存在限制。

Thanks MT_dialog

summer20100514
Offline
Last seen:4年5个月前
格鲁鲁
加入:2014-12-30 05:01
Of course I used PC to send

Of course I used PC to send data and one android application to receive data. I enabled the HW flow control, not SW flow control. When I disabled the sleep mode, everything was OK, but data lose and junk data appeared when I enabled the extended sleep mode.
I attached the log file below. I send 00 - 64 which is 101 bytes per 15ms, and data in origin_modified.txt is junk data. Thank you.

Attachment:
summer20100514
Offline
Last seen:4年5个月前
格鲁鲁
加入:2014-12-30 05:01
Have you read my last comment

Have you read my last comment ? Eager to hear from you, thank you.

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi summer20100514,

Hi summer20100514,

So the results you are getting are from a pc to pc connection or a pc to the android iOS application connection (unfortunatelly i am not able to replicate the result on my side tested on an android application and on pc to pc with hercules terminal send a file with the values 00 - 64 continuesly). Since you are using HW flow control have you properly set the wiring on your dev kits (you are using dev kits basic/pro or you are using a custom board ?). The only reason i can think of when using HW flow control, in order to miss data while sleep is enabled, or get junk, is that something is wrong with the RTS/CTS signals. In case you are using a basic kit please use a seperate FTDI chip and not the UART from the jlink. Additionally please check that the configurations on your uart terminal are set properly to the configurations of your firmare.

Thanks MT_dialog

summer20100514
Offline
Last seen:4年5个月前
格鲁鲁
加入:2014-12-30 05:01
我终于发现了这个问题。

我终于发现了这个问题。当我使用HW流量控制并每15毫秒发送数据时,周期性发送定时器和HW流量控制之间存在冲突。然后我选择一个终端将整个文件发送到启用HW Flow Control,现在一切正常。谢谢mt_dialog。

YuanhangWu
Offline
Last seen:4 years 11 months ago
Expert
加入:2015-03-25 08:19
Hi Thanks MT_dialog,

Hi Thanks MT_dialog,

else
{
// check UART. If a Tx or Rx Proceess is in progress disable sleep
if (uart_sps_fifo_check())
app_disable_sleep();
else
{

app_sleep_prepare(&sleep_mode);

if (sleep_mode == mode_sleeping)
app_set_extended_sleep();

else //add
app_disable_sleep(); //add

}
}

I will try with it.

thanks.

YuanhangWu
Offline
Last seen:4 years 11 months ago
Expert
加入:2015-03-25 08:19
Hi Thanks MT_dialog,

Hi Thanks MT_dialog,
I have try it:
else
{
// check UART. If a Tx or Rx Proceess is in progress disable sleep
if (uart_sps_fifo_check())
app_disable_sleep();
else
{

app_sleep_prepare(&sleep_mode);

if (sleep_mode == mode_sleeping)
app_set_extended_sleep();

else //add
app_disable_sleep(); //add

}
}

问题没有解决。

结果是:
PC link BLE with uart.
configuration mode:
PC send only one command (close advertising) repeat cycle. the tip back to PC is not follow every command;but every tip back to PC is 00,
有时回到pc是\ r \ nok \ r \ n(这是正确的提示)

I want the tip back to PC is follow every command.
请给我帮助。

thanks.