DPSP数据丢失的睡眠ode

12 posts / 0 new
Last post
YuanhangWu
Offline
Last seen:5年23小时前
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\u ConfigurePin(UART1\u RTS\u端口,UART1\u RTS\u PIN,输出,PID\u UART1\u RTSN,false);
GPIO_ConfigurePin( UART1_CTS_PORT, UART1_CTS_PIN, INPUT_PULLUP, PID_UART1_CTSN, false );
#endif /*UART_HW_FLOW_ENABLED*/
//GPIO\u ConfigurePin(GPIO\u BUTTON\u PORT,GPIO\u BUTTON\u PIN,INPUT\u PULLDOWN,PID\u GPIO,false);
}

PC UART<----流1--->BLE UART<----流2--->电话。
我要做的是:
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?

please give me help.
thanks.

Device:
MT_dialog
Offline
Last seen:3 months 2 days 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\u sleep\u 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:3 months 2 days 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:3 months 2 days ago
Staff
加入:2015-06-08 11:34
Hi summer20100514,

Hi summer20100514,

我假设您使用的是外部MCU而不是pc(请您尝试一下pc和android或iOS应用程序或pc2pc连接,并检查结果是否相同),您在系统中使用的流量控制设置是什么,也可以给我一些有关您的设置的信息吗?此外,如果您正在使用软件流控制,则在使用延长睡眠时会有限制。

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:3 months 2 days 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
I found the problem at last.

我终于发现了问题。当我使用硬件流量控制,每15毫秒发送一次数据时,周期发送计时器和硬件流量控制之间存在冲突。然后我选择一个终端发送整个文件,启用了工作流控制,现在一切都好了。谢谢你的对话。

YuanhangWu
Offline
Last seen:5年23小时前
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:5年23小时前
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.