Hi,all.
In dsps project "DA14580_DSPS_3.150.2" ,perpheral device.
已打开UART\U HW\U FLOW\U ENABLED。
set like this.
#define CFG_UART_HW_FLOW_CTRL
#undef CFG_UART_SW_FLOW_CTRL
#define CFG_EXT_SLEEP
#深度睡眠
When connected,but also lose data Frequently,sometimes get data,sometimes are not.
Why,and how to handler this problem.
thanks.
Keywords:
Device:
Hi YuanhangWu,
Can you give me your setup please? You are using the DSPS android application and you lose data ? Is the data rate within the predefined DSPS performance? With sleep udefined are you still losing data? You can use SW flow control without using CTS RTS pins by definingCFG\u UART\u SW\u FLOW\u CTRL。
Thanks MT_dialog
Hi,all.
In dsps project "DA14580_DSPS_3.150.2" ,perpheral device.
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_ConfigurePin(GPIO_BUTTON_PORT,GPIO_BUTTON_PIN,INPUT_PULLDOWN, PID_GPIO, false);
}
PC UART < -----Flow1----> BLE UART <-----Flow2------> Phone.
I want to do is:
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.
So ,I used pc to send BLE a data 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 close sleep and close flow control,the data is response Immediate.
I want response Immediate,and open sleep and open flow control.
How to do to solve this problem?
second step:
judge Flow2 data is not lost or wrong bit .
every phone send a data to UART,the data have a crc ckeck in the end.
this is in testing now.
please give me help.
thanks.
Hi,all
CTS i used to wake_up_irq ,when the uart have data to BLE,then let the CTS GPIO high to low to active ble,
app_force_active_mode();
when data have translated over,then let the CTS GPIO low to high,the ble to sleep.
app_restore_sleep_mode();
the wake_up_irq is not work normal ,I test when the CTS GPIO is high to low,not always go in to wake_up_irq to the app_force_active_mode();
why ?
can you help me?
Hi YuanhangWu,
Have you set the irq and the wake up controller every time before the da goes sleep?
Thanks MT_dialog
hi , MT_dialog,
Yes ,i have set like this:
无效外围初始化(void)
{
.........
app_button_enable();
........
}
in void app_button_enable(void)
{
wkupct_register_callback(app_button_press_cb);
if(uart_cts_init_flag==FALSE)
{
GPIO\u ConfigurePin(UART1\u CTS\u端口、UART1\u CTS\u PIN、INPUT\u PULLUP、PID\u UART1\u CTSN、true);
wkupct_enable_irq(0X80, 0X80, 1, 0);
uart_cts_init_flag=TRUE;
}
else
{
if(uart_cts_irq_flag ==FALSE)
//if (GPIO_GetPinStatus( GPIO_BUTTON_PORT, GPIO_BUTTON_PIN )!=FALSE)
{
GPIO\u ConfigurePin(UART1\u CTS\u端口、UART1\u CTS\u PIN、INPUT\u PULLUP、PID\u UART1\u CTSN、true);
wkupct_enable_irq(0X80, 0X80, 1, 0);
}
else
{
GPIO_ConfigurePin (UART1_CTS_PORT UART1_CTS_PIN,INPUT_PULLUP, PID_UART1_CTSN, false);
wkupct_enable_irq(0X80, 0, 1, 0);
}
}
}
in void app_button_press_cb(void)
{
if(GetBits16(SYS\u STAT\u REG,PER\u IS \u DOWN))
periph_init();
if (app_ble_ext_wakeup_get())
{
//Wakeup BLE here
#if (EXT_SLEEP_ENABLED)
app_set_extended_sleep();
#elif (DEEP_SLEEP_ENABLED)
app_set_deep_sleep();
#else
app_disable_sleep();
#endif
SetBits32(GP_CONTROL_REG, BLE_WAKEUP_REQ, 1);
app_ble_ext_wakeup_off();
}
if (GPIO_GetPinStatus( GPIO_BUTTON_PORT, GPIO_BUTTON_PIN )!=FALSE)
{
uart_cts_irq_flag =FALSE;
uart\u cts\u irq\u lastdown=0;
uart_cts_irq_lastup =1;
uart_sps_flow_off();
app_restore_sleep_mode();
}
else
{
app_force_active_mode();
uart_cts_irq_lastdown =1;
uart_cts_irq_lastup =0;
uart_cts_irq_flag =TRUE;
uart_sps_flow_on();
}
app_button_enable();
}
in app_button_enable()
uart_cts_init_flag==FALSE is only for power on set,then set wake_up_irq in app_button_enable() is as the same with app_button_press_cb.
thanks.
the wake_up_irq is not work normal ,I test when the CTS GPIO is high to low,not always go in to wake_up_irq to the app_force_active_mode();
why ?
can you help me?
thanks.
Hi,MT_dialog,
I set the irq and the wake up controller every time before the da goes sleep ,like follow.
in void app_button_press_cb(void)
{
if(GetBits16(SYS\u STAT\u REG,PER\u IS \u DOWN))
periph_init();
............
}
Hi YuanhangWu,
Is your code looking something like this ?
wkupct_register_callback(app_button_release_cb);
wkupct_enable_irq(pin, pin_pol, events_num, deb_time);
app_ble_force_wakeup();
app_ble_ext_wakeup_off();
Perhaps the irq occurs and your system falls into sleep again somewhere in your code. Also you can check with Smart Snippets how your system behaves when the pin is high through smart snippets.
Thanks MT_dialog