This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2640R2F: UART misses bytes after debugguer pause

Part Number: CC2640R2F
Other Parts Discussed in Thread: CC2640

Hello,

Another device periodically sends 20 bytes of data to the CC2640R2F :

abcdefgh \r \n
01234567 \r \n

The sample code below just echoes back the incoming data :

// ****************************************************************************
// includes
// ****************************************************************************
#include <string.h>
#include <xdc/std.h>
#include <ti/sysbios/family/arm/m3/Hwi.h>
#include "inc/hw_memmap.h"
#include "inc/hw_ints.h"
#include "icall.h"
#include <board.h>
#include "hal_types.h"
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Swi.h>
#include <ti/drivers/UART.h>
#include <ti/drivers/uart/UARTCC26XX.h>

#include "bas_niveau/uart.h"


// ****************************************************************************
// defines
// ****************************************************************************


// ****************************************************************************
// private prototypes
// ****************************************************************************

void uart_callback_rx(UART_Handle handle, void *data, size_t transferCount);
void uart_callback_tx(UART_Handle handle, void *data, size_t transferCount);


//*****************************************************************************
// globals
//*****************************************************************************


static UART_Handle uartHandle; // handle servant à manipuler le périphérique UART
static uint8_t rx_byte; // octet pour stocker les caractères reçus

//! \brief UART Object. Initialized in board specific files
extern UARTCC26XX_Object uartCC26XXObjects[];



//*****************************************************************************
// private functions
//*****************************************************************************

/*********************************************************************
 * @fn      cb_rx()
 * @brief   Callback appelé par le bas niveau lors de la réception d'un caractère
 * @param   handle: handle de l'UART,
 * @param   *data: pointeur vers les données reçues
 * @param   transferCount: nb d'octets reçus
 * @return  None
 */
void cb_rx(UART_Handle handle, void *data, size_t transferCount)
{
    ICall_CSState key;
    key = ICall_enterCriticalSection();

    UART_write(uartHandle, data, 1);

    UART_read(handle, data, 1);

    ICall_leaveCriticalSection(key);
}



//
/*********************************************************************
 * @fn      cb_tx()
 * @brief   Callback appelé par le bas niveau lors de la fin de l'envoi d'un caractère
 * @param   handle: handle de l'UART,
 * @param   *data: pointeur vers les données reçues
 * @param   transferCount: nb d'octets reçus
 * @return  None
 */
void cb_tx(UART_Handle handle, void *data, size_t transferCount)
{
    ICall_CSState key;
    key = ICall_enterCriticalSection();




    ICall_leaveCriticalSection(key);
}




//*****************************************************************************
// public functions
//*****************************************************************************



/*********************************************************************
 * @fn      uart_init()
 * @brief   Initialise l'UART du module BLE
 * @param   callbacks applicatifs TX et RX
 * @return  None
 */
void uart_init(void *callback_applicatif_tx_, void *callback_applicatif_rx_)
{
    UART_Params params;

    // Initialize the UART driver
    UART_init();

    // Configure UART parameters.
    UART_Params_init(&params);
    params.baudRate = 1200;
    params.readDataMode = UART_DATA_BINARY;
    params.writeDataMode = UART_DATA_BINARY;
    params.dataLength = UART_LEN_8;
    params.stopBits = UART_STOP_ONE;
    params.readMode = UART_MODE_CALLBACK;
    params.writeMode = UART_MODE_CALLBACK;
    params.readEcho = UART_ECHO_OFF;

    params.readCallback = cb_rx;
    params.writeCallback = cb_tx;

    // Open / power on the UART.
    uartHandle = UART_open(Board_UART0, &params);

    //Enable Partial Reads on all subsequent UART_read()
    UART_control(uartHandle, UARTCC26XX_CMD_RETURN_PARTIAL_ENABLE,  NULL);

    UART_read(uartHandle, &rx_byte, 1);
}

Everything works well until I pause and then restart the CC2640. Since this point, many bytes are missed

The issue is here even at a very low baudrate (1200 bds).

Here is the echoed back data :

1357
abcdefgh
1357
abcdefgh
1357
abcdefgh
1357
abcdefgh
1357
abcdefgh
1357

This issue does not appear if I send the 20 bytes every 1000 ms.

However it appears if data is sent every 400 ms.

Since 20 bytes @ 1200-8-N-1 needs 166 ms to be sent, normally there's plenty of free time and I don't understand why bytes are missed.

Thanks.

  • Hello Damien,

    You should evaluate the UART performance without the debugger since it should not be connected during normal operation.  Debugger configurations and settings could be affecting the results you are observing.  Based on your code and use case, I would recommend using UART_RETURN_NEWLINE, disabling partial reads, and increasing the UART read buffer since newline characters are being used.  You can also disable write callbacks if they are not used for any application purpose.

    Regards,
    Ryan