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.

LAUNCHXL-F28379D: Hardware loop test for SCIB TX and RX pins on LAUNCHXL-F28379D

Part Number: LAUNCHXL-F28379D
Other Parts Discussed in Thread: C2000WARE

Is it possible to short the SCIB TX and RX pins on Launchpad LAUNCHXL-F28379D ,( i.e. the J1 pin 3 and 4 ) and check if the serial bits transmitted through the TX pin is being received by the RX pin. Can you share the code for that. Also, how can this information be monitored on the PC connected to the Launchpad running the Code composer studio?

  • Hi,

    Thank you for your question. An expert will get back with you for any follow-up questions.

    In the meantime, here are some answers:

    1. Yes, you can likely short the pins and view the resultant output by following the "loopback" example in C2000Ware, but with an external connection instead of internal loopback. However, If you would rather get a more representative test, using the "echoback" example instead would allow a full round trip with a host PC

    2. The code is available in both those examples, but there is no existing code to do a direct short of the pins (although it should be straightforward to do from the information I provided in 1).

    3. Yes, you can view the registers in CCS to see the results (will be able to view as raw bytes). If you use the "echoback" example, you can directly see the characters you type being written back by the device, so I would more heavily recommend that example before trying the dead-short.

    One additional note: the "loopback" examples are actually exactly what you are looking for, with the only difference being that we handle the short from TX to RX inside the device. This is a bit safer for most test applications, since there is certainty that the short is solid (sometimes jumper wires, etc. can be come loose and adds another source of error). If it is okay with you, I would recommend that example as the first you try.

    Regards,

    Vince

  • Hi Vince

    Thanks for the suggestion. I had a look at the sci_echoback example. I have the following doubts : 


    1. GPIO28 and GPIO29 are not present on J1-J8 pins of the Launchpad. Hence, I have no idea how to connect them with PC-TX and PC-RX of serial DB9 cable.


    2. For working with the code on SCI_B echoback, if I make the following changes it should work our : 

    2.1 Change all the GPIO_SetupPinMux() and GPIO_SetupPinOptions() for pins 28 and 29 to 19 and 18 respectively.

    2.2 Change all the functions of scia to scib.

  • Hi Alok,

    1. GPIO28 and GPIO29 are not present on J1-J8 pins of the Launchpad. Hence, I have no idea how to connect them with PC-TX and PC-RX of serial DB9 cable.

    The LaunchPad brings out the RX/TX signals for SCI-B and SCI-C. If you would like to use SCI-B you can use GPIO 19 (RX) and GPIO 18 (TX).

    2. For working with the code on SCI_B echoback, if I make the following changes it should work our : 

    2.1 Change all the GPIO_SetupPinMux() and GPIO_SetupPinOptions() for pins 28 and 29 to 19 and 18 respectively.

    2.2 Change all the functions of scia to scib.

    The echoback program does not require any additional hardware as-is, you should just be able to change the pin mux for the GPIOS and use the "_LAUNCHXL_F28379D" predefine in your project properties. Refer to this FAQ: https://e2e.ti.com/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/817224/faq-compiler-launchxl-f28379d-updating-default-sci-echoback-example-developed-for-control-card-to-work-with-launchpad?ReplyFilter=Answers&ReplySortBy=Answers&ReplySortOrder=Descending 

    To use SCI-B with DB9 cable, yes you will need to change the SCIA to SCIB configuration, change the pin muxing. Another thing is to add the predefine for the LaunchPad _LAUNCHXL_F28379D to the project properties, this is important so that your PLL settings are defined correctly within InitSysCtrl(). 

    Refer to this post for similar information: 

    https://e2e.ti.com/support/microcontrollers/c2000/f/c2000-microcontrollers-forum/720934/compiler-launchxl-f28379d-support-for-serial-communication 

    Best Regards,

    Marlyn

  • Hi Marlyn 

    I was able to execute the sci_echoback with SCIA configuration as per the links shared by you. Thanks for the guidance. I used putty to monitor the characters being exchanged on GPIO42 and 43. I then tried implementing the same with SCIB configuration by shorting the GPIO19 and 18 on the TI Launchpad. 
    This is my code : 

    //###########################################################################
    //
    // FILE: Example_2837xDSci_Echoback.c
    //
    // TITLE: SCI Echoback.
    //
    //! \addtogroup cpu01_example_list
    //! <h1>SCI Echoback (sci_echoback)</h1>
    //!
    //! This test receives and echo-backs data through the SCI-B port.
    //!
    //! The PC application 'hyperterminal' or another terminal
    //! such as 'putty' can be used to view the data from the SCI and
    //! to send information to the SCI. Characters received
    //! by the SCI port are sent back to the host.
    //!
    //! \b Running \b the \b Application
    //! -# Configure hyperterminal or another terminal such as putty:
    //!
    //! For hyperterminal you can use the included hyperterminal configuration
    //! file SCI_96.ht.
    //! To load this configuration in hyperterminal
    //! -# Open hyperterminal
    //! -# Go to file->open
    //! -# Browse to the location of the project and
    //! select the SCI_96.ht file.
    //! -# Check the COM port.
    //! The configuration file is currently setup for COM1.
    //! If this is not correct, disconnect (Call->Disconnect)
    //! Open the File-Properties dialogue and select the correct COM port.
    //! -# Connect hyperterminal Call->Call
    //! and then start the 2837xD SCI echoback program execution.
    //! -# The program will print out a greeting and then ask you to
    //! enter a character which it will echo back to hyperterminal.
    //!
    //! \note If you are unable to open the .ht file, or you are using
    //! a different terminal, you can open a COM port with the following settings
    //! - Find correct COM port
    //! - Bits per second = 9600
    //! - Date Bits = 8
    //! - Parity = None
    //! - Stop Bits = 1
    //! - Hardware Control = None
    //!
    //! \b Watch \b Variables \n
    //! - LoopCount - the number of characters sent
    //!
    //! \b External \b Connections \n
    //! Connect the SCI-B port to a PC via a transceiver and cable.
    //! - GPIO28 is SCI_B-RXD (Connect to Pin3, PC-TX, of serial DB9 cable)
    //! - GPIO29 is SCI_B-TXD (Connect to Pin2, PC-RX, of serial DB9 cable)
    //!
    //
    //###########################################################################
    // $TI Release: F2837xD Support Library v210 $
    // $Release Date: Tue Nov 1 14:46:15 CDT 2016 $
    // $Copyright: Copyright (C) 2013-2016 Texas Instruments Incorporated -
    // http://www.ti.com/ ALL RIGHTS RESERVED $
    //###########################################################################

    //
    // Included Files
    //
    #include "F28x_Project.h"

    //
    // Globals
    //
    Uint16 LoopCount;

    //
    // Function Prototypes
    //
    void scib_echoback_init(void);
    void scib_fifo_init(void);
    void scib_xmit(int a);
    void scib_msg(char *msg);

    //
    // Main
    //
    void main(void)
    {
    Uint16 ReceivedChar;
    char *msg;

    //
    // Step 1. Initialize System Control:
    // PLL, WatchDog, enable Peripheral Clocks
    // This example function is found in the F2837xD_SysCtrl.c file.
    //
    InitSysCtrl();

    //
    // Step 2. Initialize GPIO:
    // This example function is found in the F2837xD_Gpio.c file and
    // illustrates how to set the GPIO to it's default state.
    //
    InitGpio();

    //
    // For this example, only init the pins for the SCI-B port.
    // GPIO_SetupPinMux() - Sets the GPxMUX1/2 and GPyMUX1/2 register bits
    // GPIO_SetupPinOptions() - Sets the direction and configuration of the GPIOS
    // These functions are found in the F2837xD_Gpio.c file.
    //
    GPIO_SetupPinMux(19, GPIO_MUX_CPU1, 0x2);
    GPIO_SetupPinOptions(28, GPIO_INPUT, GPIO_PUSHPULL);
    GPIO_SetupPinMux(18, GPIO_MUX_CPU1, 0x2);
    GPIO_SetupPinOptions(29, GPIO_OUTPUT, GPIO_ASYNC);

    //
    // Step 3. Clear all __interrupts and initialize PIE vector table:
    // Disable CPU __interrupts
    //
    DINT;

    //
    // Initialize PIE control registers to their default state.
    // The default state is all PIE __interrupts disabled and flags
    // are cleared.
    // This function is found in the F2837xD_PieCtrl.c file.
    //
    InitPieCtrl();

    //
    // Disable CPU __interrupts and clear all CPU __interrupt flags:
    //
    IER = 0x0000;
    IFR = 0x0000;

    //
    // Initialize the PIE vector table with pointers to the shell Interrupt
    // Service Routines (ISR).
    // This will populate the entire table, even if the __interrupt
    // is not used in this example. This is useful for debug purposes.
    // The shell ISR routines are found in F2837xD_DefaultIsr.c.
    // This function is found in F2837xD_PieVect.c.
    //
    InitPieVectTable();

    //
    // Step 4. User specific code:
    //
    LoopCount = 0;

    scib_fifo_init(); // Initialize the SCI FIFO
    scib_echoback_init(); // Initialize SCI for echoback

    msg = "\r\n\n\nHello World!\0";
    scib_msg(msg);

    msg = "\r\nYou will enter a character, and the DSP will echo it back! \n\0";
    scib_msg(msg);

    for(;;)
    {
    msg = "\r\nEnter a character: \0";
    scib_msg(msg);

    //
    // Wait for inc character
    //
    while(ScibRegs.SCIFFRX.bit.RXFFST == 0) { } // wait for empty state

    //
    // Get character
    //
    ReceivedChar = ScibRegs.SCIRXBUF.all;

    //
    // Echo character back
    //
    msg = " You sent: \0";
    scib_msg(msg);
    scib_xmit(ReceivedChar);

    LoopCount++;
    }
    }

    //
    // scib_echoback_init - Test 1,SCIA DLB, 8-bit word, baud rate 0x000F,
    // default, 1 STOP bit, no parity
    //
    void scib_echoback_init()
    {
    //
    // Note: Clocks were turned on to the SCIB peripheral
    // in the InitSysCtrl() function
    //

    ScibRegs.SCICCR.all = 0x0007; // 1 stop bit, No loopback
    // No parity,8 char bits,
    // async mode, idle-line protocol
    ScibRegs.SCICTL1.all = 0x0003; // enable TX, RX, internal SCICLK,
    // Disable RX ERR, SLEEP, TXWAKE
    ScibRegs.SCICTL2.all = 0x0003;
    ScibRegs.SCICTL2.bit.TXINTENA = 1;
    ScibRegs.SCICTL2.bit.RXBKINTENA = 1;

    //
    // SCIA at 9600 baud
    // @LSPCLK = 50 MHz (200 MHz SYSCLK) HBAUD = 0x02 and LBAUD = 0x8B.
    // @LSPCLK = 30 MHz (120 MHz SYSCLK) HBAUD = 0x01 and LBAUD = 0x86.
    //
    ScibRegs.SCIHBAUD.all = 0x0002;
    ScibRegs.SCILBAUD.all = 0x008B;

    ScibRegs.SCICTL1.all = 0x0023; // Relinquish SCI from Reset
    }

    //
    // scib_xmit - Transmit a character from the SCI
    //
    void scib_xmit(int a)
    {
    while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}
    ScibRegs.SCITXBUF.all =a;
    }

    //
    // scib_msg - Transmit message via SCIB
    //
    void scib_msg(char * msg)
    {
    int i;
    i = 0;
    while(msg[i] != '\0')
    {
    scib_xmit(msg[i]);
    i++;
    }
    }

    //
    // scib_fifo_init - Initialize the SCI FIFO
    //
    void scib_fifo_init()
    {
    ScibRegs.SCIFFTX.all = 0xE040;
    ScibRegs.SCIFFRX.all = 0x2044;
    ScibRegs.SCIFFCT.all = 0x0;
    }

    //
    // End of file
    //

    This is at present not working. The execution is stuck in this while loop : 

        while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}

    Any suggestions on this?

  • Hi Alok,

    Let me check on this and get back to you on Monday.

    Best Regards,

    Marlyn

  • hello,

    you need to change

    GPIO_SetupPinOptions(19, GPIO_INPUT, GPIO_PUSHPULL);
    GPIO_SetupPinOptions(18, GPIO_OUTPUT, GPIO_ASYNC);

  • Hi 

    I made this change : 

    GPIO_SetupPinOptions(19, GPIO_INPUT, GPIO_PUSHPULL);
    GPIO_SetupPinOptions(18, GPIO_OUTPUT, GPIO_ASYNC);

    but it is not working. The same problem persists. 

  • Hi Alok,

    The physical connection that maps to the FTDI chip on the launchpad is through the SCIA TX/RX pins. If you want to use SCIB then you will need to have an external FTDI connector/UART-to-USB transceiver. My comment above for not needing additional hardware was for using SCIA, apologies for not being clear about that.

    Best Regards,

    Marlyn

  • Hi Marlyn

    I don't have an FTDI connector, can I use a USB to RS 232 connector. The 9 pin RS 232 connector has TX and RX pins. Can both these pins be used to connect with SCIB RX and SCIB TX pins respectively to establish the connection?

  • Hi Alok,

    Yes, this is another option.

    Best Regards,

    Marlyn

  • Hi Marlyn

    I couldn't test the above communication with the USB to RS-232 converter. However, I used two launchpads and I was able to transmit and receive data through SCI pins. Thanks for the help.