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.

SCI transmission

I am using a Keil evaluation board, MCBTMS570, (purchased from TI), and I'm having trouble getting data to show up on the TX pins.

I am using the Keil development tools set. I tried using the demonstration program called "Blinky" and while it's supposed to be outputting data on the TX pins,and breakpoints confirm that data is being written, nothing comes out on the TX pin, (and the little itty bitty LED for TX doesn't light up).

I've written code that uses the SER_init()  routine from "Blinky" board example, with modifications for baud rate, and setting the LOOP bit.In a tight loop, I write to the transmitter whenever the TX buffer is empty, and  I count the number of times the the transmit buffer becomes empty in a second, and it matches the expected values for the value set in the baud rate. In LOOP mode, I read the SCI receive data, and I receive precisely what I transmit. I've tried the same code with both SCI 1 and SCI2 with the same results.

What am I doing wrong?

  • Hi John,

    You won't not see anything on TX pin if you set the loop bit. Setting the LOOP BACK bit is to connect the transmitter to the receiver internally.

    On MDK, the SCI2 signals are routed onto the expansion connector, but SCI1 signals are routed to miniUSB through FTDI chip as default. If you want to probe SCI1 signals (RX, or TX) at expansion connector, you need to populate two resistors: R69, and R70 (0 ohms).

    regards,

    QJ

  • Didn't help.

    I'm using the code listed below. As you can see it 1) initializes the SCI port, and loops sending and receiving characters. If the LOOP BACK bit is set in the SER_init routine, it works just fine, but without the LOOP BACK BIT set nothing shows up going out.

    Also if the definition of pLIN is changed to #define pLIN_2   ((SCI_ST *)LIN1) //to use UART 2, nothing changes - i.e. it works in LOOP BACK mode but without LOOP BACK nothing is output, and input is not recognized.

    What am I doing wrong.

    John Allen

    ////   UART TEST                  
    #include <stdio.h>
    #include <TMS570.H>
    #include "GLCD.h"
    #include "rif.h"
    typedef unsigned char bool;
    /////////////////////////////////////////////////////////////////////////
    unsigned int elapsed_seconds;
    int tick_count;
    unsigned int last_elapsed_seconds;
    extern void TIM_init (void);

    #define pLIN   ((SCI_ST *)LIN)
    #define LOOP_BACK 0x10000
    void SER_init (void) {

      pLIN->SCIGR0_UN.SCIGR0_UL   = 1;                    // set reset bit
      pLIN->SCIGR1_UN.SCIGR1_UL   = 0;          // SWnRST = 0, Clears all Flag and can config SCI
      pLIN->SCIPIO7_UN.SCIPIO7_UL = 0;          // Pull Enable  might try 6 to disable pull downs
      pLIN->SCIPIO0_UN.SCIPIO0_UL = 0x6;        // TX/RX Pin Functional
      pLIN->SCIGR1_UN.SCIGR1_UL   = 0x03000022; // Async, no parity, one stop bit
      pLIN->SCICHAR_UN.SCICHAR_UL = 7;          // 8 data bits,
      pLIN->SCIBRSR_UN.SCIBRSR_UL = 0xa0000ac;   // 27,798 baud
    //  pLIN->SCIGR1_UN.SCIGR1_UL  |= LOOP_BACK;
      pLIN->SCIGR1_UN.SCIGR1_UL  |= 0x80;       // SWnRST = 1, SCI Config is done and should not be disturbed

    }
    /////////////////////////////////////////////////////////
    int send_val_to_uart (int this_val)
    {
          if ((pLIN->SCIFLR_UN.SCIFLR_ST.TX_EMPTY_B1))
            {
                pLIN->SCITD_UN.SCITD_ST.TD_UC = this_val;
                return(1);
            }
      return(0);
    }
    ///////////////////////////////////////////////////////////
    bool read_char (char *out_c) {
        char c;
        if (pLIN->SCIFLR_UN.SCIFLR_ST.RXRDY_B1)
        {
           c =  (char)pLIN->SCIRD_UN.SCIRD_ST.RD_UC;
            *out_c = c;
            return(1);
        }
        return(0);
    }
    /////////////////////////////////////////////////////////////////////////////////
    /*----------------------------------------------------------------------------
      MAIN function
     *----------------------------------------------------------------------------*/
    int main (void) {                       /* Main Program                       */
        int ready_count;
        int read_count;
        int kludge;
        int t_val;
        char in_val;

        ready_count = 0;
        read_count = 0;
        elapsed_seconds = 0;
        last_elapsed_seconds = 0;
        
      SER_init();                           /* Serial IF initialization           */
      TIM_init();     // this routine inits a timer that will increment "elapsed_seconds" every second

        while (elapsed_seconds == last_elapsed_seconds) ;  // interesting enough that if wait is eliminated, LOOP BACK DOESN'T WORK
        last_elapsed_seconds = elapsed_seconds;
     
      while (1) {                           /* Loop forever                       */

            t_val = (int) 'A';
            if (send_val_to_uart(t_val))
            {
                ready_count++;
            }
            if (read_char (&in_val))
            {
                read_count++;
                if (in_val != 'A')
                {
                    kludge++;      //
                }
            }
            if (elapsed_seconds != last_elapsed_seconds)
            {
                last_elapsed_seconds = elapsed_seconds;
                ready_count = 0;
                read_count = 0;
            }
      }
    }
    /////////////////////////////////////////////////////////////////////////////