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.

CC3220SF: UART1 Issue for modbus protocol

Part Number: CC3220SF


I am using uart1 for modbus protocol.

1) issue on callback mode first time calling uart1 function it will goto callback function there i am not received any data.

 unit8_t test_char; 
/* Create UART process */
    UART_Params_init(&uartParams);
    uartParams.writeDataMode = UART_DATA_BINARY;
    uartParams.readDataMode = UART_DATA_BINARY;
    uartParams.readReturnMode = UART_RETURN_FULL;
    uartParams.readEcho = UART_ECHO_OFF;
    uartParams.stopBits = UART_STOP_ONE;
    uartParams.parityType = UART_PAR_EVEN;
    uartParams.baudRate = 9600;
    uartParams.readCallback = uart_isr_callback;
    uartParams.readMode = UART_MODE_CALLBACK;

while(1)
{
        //Here message queue and semaphore is there
        GPIO_write(CUSTOM_UART1_RTS, 1);
        u_count = UART_write(uart, (char *) my_recv_data.msgptr, my_recv_data.msg_len);
        GPIO_write(CUSTOM_UART1_RTS, 0);
        u_count = UART_read(uart, &test_char, 1);
}

void uart_isr_callback (UART_Handle handle, void *buf, size_t count){
  char recv_data[300] = (uint8_t*)buff;
}


count size i am getting 1 and buf 0 but modbus slave response is 248 bytes.

Why i not able to get response ?

2) Issue on BLOCKING_MODE.

   Configuration:

   

uartParams.readTimeout = UART_READ_WAIT; // 3000
uartParams.writeMode = UART_MODE_BLOCKING;
uartParams.readMode = UART_MODE_BLOCKING

//Here message queue and semaphore is there GPIO_write(CUSTOM_UART1_RTS, 1); u_count = UART_write(uart, (char *) my_recv_data.msgptr, my_recv_data.msg_len); GPIO_write(CUSTOM_UART1_RTS, 0); u_count = UART_read(uart, output, read_size);

Suppose meter not sending response within 3sec read function not waiting for response ?

After sending next modbus request read function return some junk data but meter sending proper response read function getting some junk data.

Why receive function not working properly ?

Thank You

  Vasu

  • Hello Vasu,

    In callback mode what is read_size in uart_read?

    Jesu
  • Hi Jesu,

    If i send modbus request to meter.
    meter response is 248 bytes.
    Document mentioned first time calling read function receiving one byte remaining data receiving in callback function but callback function not receiving any data and count also zero.

    uint8_t test_char;
    u_count = UART_read(uart, &test_char, 1); // Read_size is one byte.

    Please see blocking mode issue also.

    Vasu
  • Hi Vasu,

    For callback mode UART_read will always return 0. You're giving UART_read a buffer of size 1. So when the buffer is full (one character) callback is triggered.

    I did not understand you're question for blocking mode. You want to know why you get junk data?

    Jesu
  • Hi Jesu,

    For callback mode first time UART_read call only i need to pass total receive data size ?

    uint8_t test_cha[300]r;
    u_count = UART_read(uart, test_char, 264); //

    After UART_read call data buffer is full callback function is trigger.
    This also same like a blocking mode if i call UART_read i can get all data then what is the use of callback mode ?

    2) issue on blocking mode

    I found issue on get junk data.
    UART_read size is a issue i passed less than meter response receive data size.
    Next time UART_write call i am sending meter request. // write working properly
    But this time UART_read i passed correct receive size not receiving data get some junk data.
    Problem is if i call one time UART_read function with wrong response size after that every response i am getting junk data only.
    How to solve this issue ?

    Vasu
  • Hi Vasu,

    1) Yes.

    2) Looks like you're missing & on UART_read output.

    Jesu