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

Hi,all.

In DSPS project,I have two work mode.
One is:
sps mode:
ble to send and receive data with phone.
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------> Phone.
我要做的是:
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.

I think the reason is the sleep and flow control,because when i
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 3 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 years 5 months ago
Guru
加入:2014-12-30 05:01
Hi, I placed the code snippet

Hi, I placed the code snippet in app_sleep_check function, but the data is lost as well.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 3 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 years 5 months ago
Guru
加入: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 3 weeks ago
Staff
加入:2015-06-08 11:34
Hi summer20100514,

Hi summer20100514,

I suppose that you are using an external MCU and not a pc (can you please give it a try with a pc and the android or iOS application or a pc2pc connection, and check whether the results are the same), what is your flow control settings that you are using in your system, also can you please give me some info about your setup ? Additionally in case that you are using SW flow control there is a limitation when using extended sleep.

Thanks MT_dialog

summer20100514
Offline
Last seen:4 years 5 months ago
Guru
加入: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 years 5 months ago
Guru
加入: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 3 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 years 5 months ago
Guru
加入:2014-12-30 05:01
I found the problem at last.

I found the problem at last. When I used HW flow control and sent data every 15 ms, there was conflict between the periodic send timer and HW flow control. Then I choose one terminal to send the entire file with HW flow control enabled, and everything is OK now. Thank you 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

}
}

the problem is not solved.

The result is :
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,
sometime back to PC is \r\nOK\r\n (this is right tip)

I want the tip back to PC is follow every command.
Please give me help.

thanks.