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.

CC1352R: Error_policyMin

Part Number: CC1352R

Tool/software:

Hello,

i have an UART as callback and get Data with a python script over the serial interface. The Data will not be read in,  it goes dirctly in the Error_policyMin. 

Can someone explain me why? 

C Code:

/*
* ======== callbackFxn ========
* Function is called, when data is read via UART
*/
void callbackFxn(UART2_Handle handle, void *buffer, size_t count,
void *userArg, int_fast16_t status)
{
if (status != UART2_STATUS_SUCCESS)
{
/* RX error occured in UART2_read() */
printf("UART RX error: %d\n", status);

}

numBytesRead = count; // Number of reading Bytes
sem_post(&sem_uart); // Erhöht Semaphore um 1 -> Anderer Thread darf weiterarbeiten
}

/*
* ======== uart_main ========
*/
void *main_uart(void *arg0)
{
uint8_t buffer[UART_BUFFER_SIZE]; /* Buffer for UART */
UART2_Handle uart;
UART2_Params uartParams;
int32_t semStatus;
uint32_t status = UART2_STATUS_SUCCESS;

/* Call driver init functions */
GPIO_init();

/* Create semaphore, 0 means semaphore is locked */
semStatus = sem_init(&sem_uart, 0, 0);
printf("semStatus error: %d\n", semStatus);
if (semStatus != 0)
{
/* Error creating semaphore */
printf("semStatus error: %d\n", semStatus);
}

/* Create a UART in CALLBACK read mode */
UART2_Params_init(&uartParams);
uartParams.readMode = UART2_Mode_CALLBACK;
uartParams.readCallback = callbackFxn;
uartParams.baudRate = 115200;

uart = UART2_open(CONFIG_UART2_0, &uartParams);

if (uart == NULL)
{
/* UART2_open() failed */
printf("UArt_open error: %d\n", uart);
}

/* Loop forever echoing */
while (1)
{
numBytesRead = 0;
printf("vor Uart read");
/* Pass NULL for bytesRead since it's not used in this example */
status = UART2_read(uart, buffer, sizeof(buffer), NULL); // UART is configured as callback -> callbackFxn is called, if Reading is done
printf("nach Uart read");
if (status != UART2_STATUS_SUCCESS)
{
/* UART2_read() failed */
printf("UART RX error: %d\n", status);

}

printf("vor sem_wait");
/* Wait until UART-read callback (callbackFxn) executes and release sem_uart*/
sem_wait(&sem_uart); //

  • Hi David,

    It looks like you started your project from the uart2callback example. Is this correct? Did the example run without error?

    Do I understand correctly that when you run the program it runs fine until you send UART data from your PC using a python script. The that you get is in the read callback?

    Could you please check the connection parameters (baud rate, parity, stop bit, flow control). They need to be set in your python script as configured for the embedded UART.

    Kind regards,
    Theo

  • I tried the Callback2Uart Project an it is running with the same python script. 

    I increased the Task-Stacksize to 2048 but it does not change anything. 

    For better understanding, I debugged the code and the Error Policy execute at the position: sem_wait(&sem_uart); when the first UARt message is send from the script.  So, the Error_policy execute only after an incoming Uart-Message. when no UART Message receive, the code runs normal. 

    I hope ypu can help me with this. 
     

  • Hi David,

    could you verify that your python script uses the same UART settings as the embedded UART configuration (baud rate, parity, stop bit, flow control) ?

    When you say debugging: Do you run the device with an active debug session or does the error also occur when running the device without debug session connected?

    Kind regards,
    Theo