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.

RM44L920: SCI Non-interrupt mode data recieved is not consistent.

Part Number: RM44L920

I am using LIN as SCI mode (SCI2) to only recieve message which i am sending over UART from ESP32 board.When i try to recieve the message the data recieved is not consistent over time some random data is recieved.

I am attaching my code below:

void get_gps(){
    j=0;
    sciReceiveByte(scilinREG);
    char c = scilinREG->RD;
    if(c=='$'){
             sciReceive(scilinREG,BUFFER_SIZE,(unsigned char *)rxBuffer);

             char *token;

                 token = strtok(rxBuffer,",");
                 latitude = strtod(token,&endptr);

                 while (token != NULL && j<4) {

                     if (j ==1) {
                       longitude = strtod(token,&endptr);
                     }
                     else if (j == 2) {
                         velocity = strtod(token,&endptr);
                     }
                     else if(j==3){
                        altitude = strtod(token,&endptr);
                     }

                     token = strtok(NULL,",");
                     j++;
                 }
          }
    }

BUFFER_SIZE = 32 ,char rxBuffer[BUFFER_SIZE];

SCI data formats : baud rate -115200 , stop bits - 1 , parity - even ,parity - enable , data bits -8.

  • Hi Karthik,

    Can you try below slightly modified code? The modification is "sciReceiveByte" it self returns the character from RD register, so no further read from RD register is required.

    void get_gps(){
        j=0;

        char c;
        c = sciReceiveByte(scilinREG);


        if(c=='$'){
                 sciReceive(scilinREG,BUFFER_SIZE,(unsigned char *)rxBuffer);

                 char *token;

                     token = strtok(rxBuffer,",");
                     latitude = strtod(token,&endptr);

                     while (token != NULL && j<4) {

                         if (j ==1) {
                           longitude = strtod(token,&endptr);
                         }
                         else if (j == 2) {
                             velocity = strtod(token,&endptr);
                         }
                         else if(j==3){
                            altitude = strtod(token,&endptr);
                         }

                         token = strtok(NULL,",");
                         j++;
                     }
              }
        }

    --

    Thanks & regards,
    Jagadish.

  • Hi jadish,

    Sure i will test and btw do the above method is fast and accurate for recieving SCI data or should i use interrupt method.

  • Hi Karthik,

    the above method is fast and accurate for recieving SCI data or should i use interrupt method.

    The above method is good if your code doesn't have any other modules code to execute, but if your code involves multiple modules of code then it would be better to go for interrupt method instead of polling till the characters received.

    --

    Thanks & regards,
    Jagadish.

  • Hi Jagadish,

    Yes , i have some other modules also such as CAN ,SPI,ADC .so can you send me a code which i could replicate the same above code with interrupt mode.

  • Hi Karthik,

    Yes, you can go for interrupt mode for optimized solution.

    --

    Thanks & regards,
    Jagadish.