Custom DSPS application not receiving all bytes

5 posts / 0 new
Last post
ao
Offline
Last seen: 1 week 6 days ago
Joined: 2016-06-02 20:58
Custom DSPS application not receiving all bytes

Hi Dialog,

I am currently developing firmware using the DSPS application with a DA14580 chip on a custom board. In this project, I am using a GPIO pin to turn on and off an external microcontroller in order to conserve power when the microcontroller is not in use. When I need to use the microcontroller, I send a short command to the DA14580 using a mobile phone, the DA14850 then wakes up the external microcontroller with a GPIO pin, sets up the UART, sends the short command, then waits to receive data to send to the phone.

Without turning on/off the external microcontroller, I am able to send data back and forth between the microcontroller and phone successfully. However, I think that when I am reconfiguring the pins during runtime, it is causing data to be lost when receiving and sometimes causing the DA14580 to get hung up somewhere. (a watchdog reset occurs if watchdog is enabled, and the phone is disconnected from Bluetooth and the device no longer advertises if watchdog is disabled)

On bootup, in the "set_pads_function" the pins will be set to GPIO output low to prevent any voltage on the pins of the external microcontroller.

When I connect to the device from a phone, I disable sleep mode.

In the function "user_sps_server_data_rx_ind_handler", I start a timer I use to handle my application processes.

The first time the timer callback occurs, I configure the pins to turn on my external microcontroller and set up my UART pins. TX, RX, CTS, and RTS. (I have HW flow control defined)

After a couple seconds, for testing purposes, I disable the timer in case it is causing any problems. Then, I send the outgoing command to the external microcontroller. I can see that the external microcontroller has received and processed the command correctly.

The external microcontroller then sends 3000+ bytes to the DA14580 in 240 byte chunks.

At this point, I can see that all of the bytes have been sent over UART on a scope. The DA14580 will respond either one of two ways:
1. The device is disconnected from the DSPS mobile app and is stuck in some state.
2. If the device doesn't get stuck. I can look at the amount of bytes received from the DSPS mobile app, there will be ~1940 bytes in the last receive file.

If I initially set up the pins as UART and have the microcontroller "on", the DA14580 is able to handle the 240 byte chunks without HW flow control enabled. The DA14580 is also able to handle the 240 byte chunks with flow control enabled without setting the RTS pin during a transmission.

There are a couple things I suspect could be causing the problem:
Is there anything I need to do when I reconfigure the pins from GPIO to UART during runtime?
Is there anything I need to do with the SPS scheduler when I am reconfiguring the pins that could be causing me to not be able to process all 3000+ bytes?

Anything helps, thank you for your time

Keywords: 
Device: 
PM_Dialog
Offline
Last seen: 4 days 13 hours ago
Staff
Joined: 2018-02-08 11:03
Hi ao,

Hi ao,

Let me check your issue and I will get back to you as soon as possible.

Thanks, PM_Dialog

PM_Dialog
Offline
Last seen: 4 days 13 hours ago
Staff
Joined: 2018-02-08 11:03
Hi ao,

Hi ao,

As you mentioned, you have modified the DSPS reference application code according to your application’s need, so it is little bit difficult o replicate your issue. Could you please let me know where the code gets stuck?

  • “a watchdog reset occurs if watchdog is enabled, and the phone is disconnected from Bluetooth and the device no longer advertises if watchdog is disabled”

 

Could you please enable the WDOG, run the firmware with hot-attaching the debugger? Which is the reason of WDOG expiration?

 

  • “I think that when I am reconfiguring the pins during runtime, it is causing data to be lost when receiving and sometimes causing the DA14580 to get hung up somewhere.”

How you reconfigure the pins during runtime? Do you call the periph_init() ?

 

  • In case you have a custom board with the DA14580 chip, could you please let me know that when using the default DSPS application is fully functional?

 

  • “Is there anything I need to do with the SPS scheduler when I am reconfiguring the pins that could be causing me to not be able to process all 3000+ bytes?”

 

I not quite sure what you mean with this question, so can you please try to explain It a little bit more?

Thanks, PM_Dialog

ao
Offline
Last seen: 1 week 6 days ago
Joined: 2016-06-02 20:58
I haven't been working on

I haven't been working on this specific problem lately, but will be getting back to it soon. Let me respond quickly to what I can right now:

1. How can I see the reason for wdog expiration?

2. What is the best way to reconfigure pins? I am calling a function that changes the pins shown below. Also, the flag "sam_on" is used in periph_init() to decide whether to set the pins as GPIO or UART. I think that periph_init() is called each time that the device wakes from sleep, is this true?

void turn_off_sam(void)
{
GPIO_SetPinFunction(GPIO_UART1_TX_PORT, GPIO_UART1_TX_PIN, INPUT, PID_GPIO);
GPIO_SetPinFunction(GPIO_UART1_RX_PORT, GPIO_UART1_RX_PIN, INPUT, PID_GPIO);
#if (UART_HW_FLOW_ENABLED)
GPIO_SetPinFunction(GPIO_UART1_RTS_PORT, GPIO_UART1_RTS_PIN, INPUT, PID_GPIO);
GPIO_SetPinFunction(GPIO_UART1_CTS_PORT, GPIO_UART1_CTS_PIN, INPUT, PID_GPIO);
#endif //UART_HW_FLOW_ENABLED

GPIO_ConfigurePin(GPIO_PORT_1, GPIO_PIN_0, OUTPUT, PID_GPIO, true);

sam_on = false;
}

3. DSPS is fully functional as long as I am not turning on/off the external microcontroller.

4. I've noticed that the sps scheduler is reinit before and after sleeping. is it possible to deinit the sps scheduler completely and then initialize the sps when needed? Ideally, I want to be able to deinitialize the pins/sps when not needed and then reinitialize everything when needed. The SPS is not needed when a device is not connected so it will be deinitialized for this time. During a connection, I will send a command to the DA14580 from the mobile device, then the DA14580 will need to initialize SPS and turn on the external microcontroller and communicate, then turn off the microcontroller and deinitialize the SPS.

PM_Dialog
Offline
Last seen: 4 days 13 hours ago
Staff
Joined: 2018-02-08 11:03
Ho ao,

Ho ao,

1. When the watchdog times out, the NMI_HandlerC is triggered. Please check the following tutorial from our support portal in order to understand how you can debug your firmware. The procedure you should follow is the same that is described into the tutorial: https://www.dialog-semiconductor.com/sites/default/files/training_08_deb... Be aware that the maximum WDOG time out is 2.6 second, and this value we are using in the SDK.

2. You are correct, the periph_init is executed every time that the chips wakes up. Which is the sleep mode configuration that you are using? Could you please make sure tha the periph_init is correctly triggered and the reconfigurations is correctly happened? My recommendation is to reconfigure the pins into the user_periph_setup.c file

Regarding your last question, I am not completely sure what you exactly mean. Could you please clarify it a little bit more? What do you mean with “The SPS is not needed when a device is not connected so it will be deinitialized for this time.” ? My recommendation is to try to run the firmware into debug mode with the debugger hat attached and try to find where the firmware gets stuck.

Thanks, PM_Dialog