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 on one wire

Other Parts Discussed in Thread: LAUNCHXL-F28027

Hi,


I am working on LAUNCHXL-F28027 C2000 Piccolo LaunchPad.

I need a serial port running only on one wire. I started with Example_2802xSci_Echoback.c.

TxD and RxD are connected by a diode:    ( TxD  -|<|-  RxD )  

In idle oparation I have RXENA enabled and TXENA disabled.

I switch them when transmit is needed and transmit after the transmit is complete.

The communication works as expected when the RxD and TxD are separated. (no reception when transmitting).

However when I connect the pins, I receive the last sent byte anyway.

Here's the source code:

// Transmit a character from the SCI
void scia_xmit(int a)
{
    SciaRegs.SCITXBUF=a;
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
}

void scia_msg(char * msg)
{
    SciaRegs.SCICTL1.all =0x0022;
    int i;
    i = 0;

    while(msg[i] != '\0')
    {
        scia_xmit(msg[i]);
        i++;
    }

    while (SciaRegs.SCICTL2.bit.TXEMPTY == 0){}
    SciaRegs.SCICTL1.all =0x0021;
}

    Uint32 j = 0;
    for(;;)
    {
       msg = "\r\nEnter a character:\0";
       scia_msg(msg);

       // Wait for inc character
       j = 0;
       while(SciaRegs.SCIFFRX.bit.RXFFST <1) { j++;} // wait for XRDY =1 for empty state

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

       // Echo character back
       msg = "  You sent: \0";
       msg[11]  = ReceivedChar;
       scia_msg(msg);
    }

  • Hi Lukas,

    When you have Rx and Tx connected, Rx will receive what is being sent in the Tx wire because it is the same wire.

    How are you connecting the pins and wire?

    sal
  • Hi Sal,

    thank you very much for your answer.

    Yes, it is the same wire, however I use the same configuration with another MCU. (with combined TxD and RxD pins internally)

    The point is to have reception enabled. When I need to send something I'd like to disable the reception. After the message is sent I will turn off the transmission and turn on the reception. It's a half duplex on a simple line. I do not know how to call it better.

    Basically it is working with the code from the original question. The problem is that when I turn on the reception back after transmitting, I receive the last sent byte.

    It seams like the last byte is shifted in the register regardless of the disabled reception and moved to the buffer when the reception is enabled again.

    Is there a way to check some other flag or discard the buffer or anything else I could do? I could also discard the first received byte but I am not sure that the behavior is so deterministic or that no useful byte is received. BTW j counter counts to approx 950 until it "receives" the sent byte.

    I use the connection as in the schematic.

  • Hi Gastón, I am sorry for the missleading term "one-wire" while thinking of UART running on a single line. Thank you very much for your answer anyway.
  • Hello,

    is there anyone who has such experience with the SCI behavior?

    Thanks.

    Lukas

  • Hi Lukas,

    When you enable or disable Rx/Tx perform a SW RESET after each operation please. Right now you are only writing a 1 to SCICTL1.SWRESET, but in order to perform a software reset you need to write a 0 and then a 1.

    Try this and let me know if this helps.

    You can also flush the buffers by writing a 1 to SCIRST.

    sal
  • Hi Sal,

    thank you very much. You were right.

    SW Reset is enough. SCIRST to flush buffers is not needed in my case.

    So this is how it works now:

    void scia_msg(char * msg)

    {

       SciaRegs.SCICTL1.all =0x0022;

       int i;

       i = 0;

       while(msg[i] != '\0')

       {

           scia_xmit(msg[i]);

           i++;

       }

       while (SciaRegs.SCICTL2.bit.TXEMPTY == 0){}

       SciaRegs.SCICTL1.all =0x0000;

       SciaRegs.SCICTL1.all =0x0021;

    }