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.

Uart stops on ascii characters 17, 19, and 141

Hello,

I have a strange problem i have never come across before.  I am attempting to send a binary file (one byte at a time for now) from my PC, through my network, into a digi device that translates that into a serial signal connected to the TMS570 Hercules development board.  Almost everything works great except for when i am sending characters 17, 19, and 141.  If i do not send these characters, the entire file gets sent, and received by the TMS.  

I first send the TMS570 a command character which interrupts the tms570.  The tms then turns off interrupts and receives the file size, goes into polling loop to grab one character at a time until the file size has been reached.  However, when it receives one of the above ascii characters, the code stalls at this line:

while ((sci->FLR & SCI_RX_INT) == 0U)
{
} /* Wait */

Which obviously is supposed to stall for some cases, but in these cases i do have a character sent, so the receive buffer should be ready, and interrupts were turned off.  I am sorry if this is very hard to follow, i am having a hard time explaining what is happening.

I could post some code if needed,  but i wanted to see if i was blatantly missing something very stupid.  

  • Hello Larkin,

    Did you use any protocol for your data transfer, for example Kermit, ymodem? How does your digi device translate your data 17/19/141? Can you please probe SCI TX pin (pin 5 of J11 connector) to make sure the MCU gets 17/19/141 from your digi device? 

    Regards,

    QJ

  • Thank you for the reply!

    I am not using Kermit or ymodem, or any other protocol.

    The MCU does get 17/19/141 from the digi device.  This was verified via scope and by checking the RD register of the MCU at time of transmittal. 

    However, i did figure a couple of other things out ( I think ).  When a 17/19/141 are received, (sci->FLR & SCI_RX_INT) seem to always equal zero in the below code.

                while ((sci->FLR & SCI_RX_INT) == 0U)

       {} /* Wait */

    However,  by adding in this code:

    if (sci->RD == 19 || sci->RD == 17 || sci->RD == 141){

            sci->RD = sci->RD;

            }

                while ((sci->FLR & SCI_RX_INT) == 0U)

       {

           } /* Wait */

    Without the breakpoint and myself pressing the continue button afterward (the code stalls and i pause the code to check the register value) sci->FLR = 6400 or 0x1900.
    This value anded with the value of  SCI_RX_INT = 0x200 (512) gives the value of zero.

    With the breakpoint added the value of sci->FLR is 4352 in all of these cases (0x1100).  This apparantly allows the code to not equal zero (although when i and them i get 0 again).

    And placing a breakpoint at " sci->RD = sci->RD;", and then continuing allows the code to run each time without the stall.

    Is there a timing issue that only arises on these particular characters?  That seems unlikely and that i am missing some root problem, but i have never come across this before so i appreciate your help!

    Thanks

    <edit> sorry i keep adding to this, i keep finding information that may help

  • Hi Keegan,

    Can I have your SCI initialization code? I never saw this kind of issue, but I'd like to replicate the test you did on my bench. Thanks

    Regards,

    QJ 

  • Sure thing, 

    (also i tried adding code tags but still cannot figure out how to get it to work, sorry)

    <code>

    void sciInit(void)
    {
    /* USER CODE BEGIN (2) */
    /* USER CODE END */


    /** @b initialize @b SCILIN */

    /** - bring SCI out of reset */
    scilinREG->GCR0 = 1U;

    /** - Disable all interrupts */
    scilinREG->CLRINT = 0xFFFFFFFFU;
    scilinREG->CLRINTLVL = 0xFFFFFFFFU;

    /** - global control 1 */
    scilinREG->GCR1 = (1U << 25U) /* enable transmit */
    | (1U << 24U) /* enable receive */
    | (1U << 5U) /* internal clock (device has no clock pin) */
    | ((1U-1U) << 4U) /* number of stop bits */
    | (0U << 3U) /* even parity, otherwise odd */
    | (0U << 2U) /* enable parity */
    | (1U << 1U); /* asynchronous timing mode */

    /** - set baudrate */
    scilinREG->BRS = 48U; /* baudrate *///585U

    /** - transmission length */
    scilinREG->FORMAT = 8U - 1U; /* length */

    /** - set SCI pins functional mode */
    scilinREG->FUN = (1U << 2U) /* tx pin */
    | (1U << 1U) /* rx pin */
    | (0U); /* clk pin */

    /** - set SCI pins default output value */
    scilinREG->DOUT = (0U << 2U) /* tx pin */
    | (0U << 1U) /* rx pin */
    | (0U); /* clk pin */

    /** - set SCI pins output direction */
    scilinREG->DIR = (0U << 2U) /* tx pin */
    | (0U << 1U) /* rx pin */
    | (0U); /* clk pin */

    /** - set SCI pins open drain enable */
    scilinREG->ODR = (0U << 2U) /* tx pin */
    | (0U << 1U) /* rx pin */
    | (0U); /* clk pin */

    /** - set SCI pins pullup/pulldown enable */
    scilinREG->PD = (0U << 2U) /* tx pin */
    | (1U << 1U) /* rx pin */
    | (0U); /* clk pin */

    /** - set SCI pins pullup/pulldown select */
    scilinREG->PSL = (1U << 2U) /* tx pin */
    | (0U << 1U) /* rx pin */
    | (1U); /* clk pin */

    /** - set interrupt level */
    scilinREG->SETINTLVL = (0U << 26U) /* Framing error */
    | (0U << 25U) /* Overrun error */
    | (0U << 24U) /* Parity error */
    | (0U << 9U) /* Receive */
    | (0U << 8U) /* Transmit */
    | (0U << 1U) /* Wakeup */
    | (0U); /* Break detect */

    /** - set interrupt enable */
    scilinREG->SETINT = (0U << 26U) /* Framing error */
    | (0U << 25U) /* Overrun error */
    | (0U << 24U) /* Parity error */
    | (1U << 9U) /* Receive */
    | (0U << 1U) /* Wakeup */
    | (0U); /* Break detect */

    /** - initialize global transfer variables */
    g_sciTransfer_t[1U].mode = 1U << 8U;
    g_sciTransfer_t[1U].length = 0U;


    /** - Finaly start SCILIN */
    scilinREG->GCR1 |= (1U << 7U);

    /* USER CODE BEGIN (3) */
    /* USER CODE END */
    }

    </code>

    Here is the code that enters the polling loop to await the data:

    <code>

    if(data[0] == '3'){
    //Turn off interrupts
    upload = TRUE;
    scilinREG->SETINT = 0;
    scilinREG->CLRINT = 0xFFFFFFFFU;
    scilinREG->CLRINTLVL = 0xFFFFFFFFU;

    // This copies the total file size
    memcpy(data,&rx_buff[1],20);

    //convert the filesize to an integer.
    int fileSize = atoi(data);

    uint8 data[1]; //Array to store received stuff
    long i = 1;
    int number = 1;

    //As long as we havnt received more than the file has available
    while(i < (fileSize)){


    sciReceive(UART,i,rx_buff); //Receive a character
    memcpy(data,&rx_buff,i);
    sciSend(UART,i,data); //Send a character (for verificiation)
    fileSize = fileSize -1;

    }

    //sciReceive(UART,fileSize,rx_buff); //Receive a character
    //memcpy(data,&rx_buff,fileSize);
    sciSend(UART,1,data); //Send a character (for verificiation)
    //This is only used to enable interrupts
    sciInit();
    sciSend(UART,1,data); //Send a character (for verificiation)

    sciReceive(UART,50,rx_buff);

    </code>

    Thank you very much!

  • Sorry Folks,

    Looks like the problem was indeed with the digi device or the code I wrote web server side.  

    My apologies!

  • Hi keegan,

    "Almost everything works great except for when i am sending characters 17, 19, and 141.  If i do not send these characters, the entire file gets sent, and received by the TMS.  "

    My question is: how do you generate the symbols of 17, 19, and 141 (they are DC1, DC3)?

    Regards,

    QJ