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.

  • Resolved

LAUNCHXL-F28379D: SCI works only on the SCIA pin

Prodigy 160 points

Replies: 5

Views: 180

Part Number: LAUNCHXL-F28379D

Hello,

I'm trying to communicate using the SCI protocol using the LAUNCHXL-F28379D. As usual, I have read the TRM and tried the example code. The example code worked perfectly, because it uses SCIA. When I switch to use SCIB or any other one (C or D) it just doesn't work and I can't find why, even with the GPIO Mux correctly set up. This is my code, trying to talk over SCIBTX :

#include "F28x_Project.h"

#define TX 18


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


void main(void)
{
    char *msg;

    InitSysCtrl();

    // GPIO
    InitGpio();

    EALLOW;
    // Set the mux to SCITXDB on GPIO 18
    GpioCtrlRegs.GPAGMUX2.bit.GPIO18 = 0;
    GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 2;
    // Select CPU 1
    GpioCtrlRegs.GPACSEL3.bit.GPIO18 = 0;
    // Set GPIO 18 as output
    GpioCtrlRegs.GPADIR.bit.GPIO18 = 1;
    // Async mode
    GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3;
    EDIS;

    // Interrupts
    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();
    EINT;

    // SCI
    scib_fifo_init();
    scib_echoback_init();

    for (;;) {
        msg = "Salut\n\0";
        scib_msg(msg);
    }
}

void scib_echoback_init()
{
    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;  // Enable RXBKINTENA and TXINTENA

    //
    // SCIB 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
}

void scib_xmit(int a)
{
    while (ScibRegs.SCIFFTX.bit.TXFFST != 0) {}
    ScibRegs.SCITXBUF.all =a;
}

void scib_msg(char * msg)
{
    int i;
    i = 0;
    while(msg[i] != '\0')
    {
        scib_xmit(msg[i]);
        i++;
    }
}

void scib_fifo_init()
{
    ScibRegs.SCIFFTX.all = 0xE040;
    ScibRegs.SCIFFRX.all = 0x2044;
    ScibRegs.SCIFFCT.all = 0x0;
}

I'm using the flag _LAUNCHXL_F28379D for the compiler.

Thanks for your help!

  • Louis,

    I have generated a comparison report between your code and the example code with the difference highlighted.  Your configuration of the GPIO does look correct, though when configured as SCI specifying the direction is not needed.  You said that SCI-A works without any issues.  Could you let me know when using SCI-A with your LaunchPad are you communicating through the USB connection or pins?  Please review the report (your code does not have the interrupt enables).

    I hope this helps. If this answers your question, please click the green "Verified Answer" button. Thanks.

    - Ken

    /cfs-file/__key/communityserver-discussions-components-files/171/Report.html

  • In reply to Ken Schachter:

    Thanks for this answer.

    I didn't know we can do SCI through USB so I'm using the PIN connected to an Arduino which receive the SCI and give it to the computer (which works with the SCI-A so the issue doesn't come from here I think). I reviewed the report. You said : "your code does not have the interrupt enables" but

    SciaRegs.SCICTL2.all = 0x0003;

    is exactly the same as doing :

    SciaRegs.SCICTL2.bit.TXINTENA = 1;
    SciaRegs.SCICTL2.bit.RXBKINTENA = 1;

    no ?

    I did the same as you, I made a comparaison between the working SCI-A code and the not working SCI-B code. You will find it there : https://www.diffchecker.com/2NeScyi0

    Thanks again.

  • In reply to Louis Etienne:

    Louis,

    You are correct, TXINTENA and RXBKINTENA are both taken care of with SciaRegs.SCICTL2.all = 0x0003;. I am not sure why these extra code lines are there. So, we are at the point where your code for SCI-A works perfectly and you are using GPIO29. (By the way, the LaunchPad does supports PC communications through the USB/UART XDS100v2 connection for SCI-A - please see the LaunchPad manual). Now, it looks like the only changes you made are for the SCI-B structures and using GPIO18. Sorry, this might sound very basic, but please confirm that you are connected to header J1, pin #4. (I already confirmed that the SCI-B clock is enabled in InitSysCtrl();).

    Could you please try running your code for SCI-B using a different GPIO pin? I checked for SCITXDB and it is pinned out to other GPIO locations that are in common with the LaunchPad headers. Possible GPIO options (other than 18) are: 22, 14, 10, and 9. Please let me know what happens. Thanks.

    - Ken
  • In reply to Ken Schachter:

    This may sound absolutely stupid, but I just copy past the code in the original post and compile it to the Launchxl and it just works... I don't understand what changed between now and before... I'm so angry, I've been stuck on this for 4 days and now it just works for no reason except that the code was correct.. Maybe I was drunk all the time and the cable wasn't on the PIN 4?
  • In reply to Louis Etienne:

    Louis,

    I am glad to hear that it is working now.

    - Ken

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.