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.

TMS570 SCI Transmit Problem

Other Parts Discussed in Thread: MAX232

Hi there.

I have a problem with the SCI/Lin Module. When transmitting data to my PC I do not receive the first character/byte after reset.

Here is my transmit routine:

void transmit(char sendbuffer[], int len)
{
 int i;
 
 if(len < BUFFER_SIZE)
 {
  for(i=0; i < len; i++)
  {
   while ((scilinREG->FLR & SCI_TX_INT) == 0)
   {
   }
   scilinREG->TD = sendBuffer[i];
  }
 }
}

and my SCI inti routine:

void sciInit(void)
{
 // bring SCI out of reset
    scilinREG->GCR0 = 1U;
 
 // Stop SCILIN / Set SW nRST to 0
    scilinREG->GCR1 &= ~(1 << 7);
 
    // Disable all interrupts
    scilinREG->CLRINT    = 0xFFFFFFFFU;
    scilinREG->CLRINTLVL = 0xFFFFFFFFU;
 
    // global control 1
    scilinREG->GCR1 =((1 << 25)  // enable transmit
     | (1 << 24)  // enable receive
     | (1 << 17)  // Continue on Suspend Bit for debugging
     | (1 <<  5)  // internal clock (device has no clock pin)
     | ((1-1) << 4) // number of stop bits: 0->1 stop bit | 1->2 stop bits
     | (0 <<  3)  // even parity(1), otherwise odd(0)
     | (0 <<  2)  // disable parity
     | (1 <<  1)); // asynchronous timing mode
 

    // set baudrate to 115200
 // TRM Seite 1643 - 1644 | 25.13.12 Baud Rate Selection Register
 // VCLK = 80 MHz
 scilinREG->BAUD = 42;   // baudrate

    // tranmision length
    scilinREG->LENGTH = 8 - 1;  // length

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

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

    // set interrupt enable
    scilinREG->SETINT =  ((0 << 26) // Framing error
      | (0 << 25) // Overrun error
      | (0 << 24) // Pariry error
      | (1 << 9) // Receive
      | (0 << 8) // Transmit
      | (0 << 1) // Wakeup
      | (0));  // Break detect
 
 // clear interrupt flags
 scilinREG->FLR = 0xFFFFFFFF;

    // Start SCILIN
    scilinREG->GCR1 |= (1 << 7);
}

I don't know where the problem is. Am i initialising the SCI wrong?

Thanks for helping me.

Dominik

  • Dominik,

    i am guessing that PC does not receive the first byte because it does not detect the "start condition" of the first byte. Do you send a SCI message to PC right after CPU comes out of reset? Can you check if the TX line is toggled during boot up?  PC needs to see the TX line at "high" state long enough to determine that the SCI bus is "idling" before it can receive data correctly.  You can add a delay after configuring the LIN/SCI module.  This delay will enable PC to see that the the TX line is in idle state (high) before you put the first data on the bus.

    Please let me if this solves your problem.

    Thanks and regards,

    Zhaohong

  • After Reset the CPU is waiting for specific commands from the PC over SCI and then the CPU sends a response message.

    The command from the CPU is not sent right after reset. Usually I wait a few seconds before i send the command from the PC to the CPU. So there is enough delay after the startup I think.

    The problem is that after the first command from the PC the first byte of the response is not sent. The responses to the following commands is OK.

  • Dominik,

    Can you use an oscilloscope to monitor the TX line? From scope, you can see the number of bytes going from uP to PC. You can try the following S/W change to see if they would solve your problem.

    (1) At the end of sciInit(0 function, add this instruction to wait for the idle period detection

    while( scilinREG->FLR &0x4);

    (2) Change the transmit function to the following

    scilinREG->TD = sendBuffer[0];

    for(i=1; i < len; i++)
      {
       while ((scilinREG->FLR & SCI_TX_INT) == 0)
       {
       }
       scilinREG->TD = sendBuffer[i];
      }

    Please let me know if above changes would solve your problem.

    Thanks and regards,

    Zhaohong

  • Dear Zhaohong,

    thanks for your help, but that didn't work either.

    At the moment I am not provided with an oscilloscope, but i will try to watch the TX line with an oscilloscope in the next few days.

    Could it be a problem with the FTDI chip? I am using the Hercules TMS570 MCU Development Kit (TMDX570LS31HDK).

    Thanks for helping me

    Regards, Dominik.

  • Hi Dominik,

    The problem is caused by your SCI init. The TXWAKE (10th bit of FLR) is selected, so the 1st byte was treated as address. Writing 0 to TXMAKE will solve your problem. I tested on my side.

    Regards,

    QJ

  • Hi,
    I try to send something on the SCI module to the PC.

    My question is, which register address have I set? (0xFFF7E400 or 0xFFF7E500)

    I tested my code on the other SCI module (SCI/LIN) and it worked. (with 0xFFF7E500 base address)

    But on the other SCI I can't send anything to the PC.

    Thanks, 

    Sandor

  • Hi Sandor,

    Is this the same problem that you are referring to in  RE: TMS570 SCI problem. ?

    If so the obvious question to start with is how do you have the other SCI connected to your PC? 
    There's no connection on the HDK for this, so you would have had to add a chip like MAX232 and wired it to a serial port or done something like disconnect the USB serial port from one SCI and jumper it's wires to the other...

     

  • Hi,

    Thank you. Yes it was the same problem, but now it resolved.

    Regards,

    Sandor