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_echoback example can't receive data from PC via SCI-A

Other Parts Discussed in Thread: TMS320F28027, MAX232

HI ALL

I have an F28335 controlCard with docking station.  The card has a UART connected to SCIA. 

for the hardware:

I connect uart-to-usb to PC, set band at 9600/8/0/1 and check com port right.

and for the docking station I connect the U2' J9 pin to make the 28335 SCI-A-RX work.

for the source code:

DSP28_DIVSEL 2

DSP28_PLLCR 10

CPU_RATE 6.667L

CPU_FRQ_150MHZ

then start the example sci_echoback

my trouble is  pc hyperterminal could receive data from 28335; but if 28335 RX can't receive from PC' hyperterminal.

ererytime stop at   while(SciaRegs.SCIFFRX.bit.RXFFST != 1)

and  sci_echoback code is:

void main(void)
{

    Uint16 ReceivedChar;
    char *msg;
.
   InitSysCtrl();

   InitSciaGpio();

   DINT;

   InitPieCtrl();:
   IER = 0x0000;
   IFR = 0x0000;

   InitPieVectTable();

    LoopCount = 0;
    ErrorCount = 0;

    scia_fifo_init();    // Initialize the SCI FIFO
    scia_echoback_init();  // Initalize SCI for echoback

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

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

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

       // Wait for inc character
       while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { } // wait for XRDY =1 for empty state

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

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

       LoopCount++;
    }

}
void scia_echoback_init()
{
    // Note: Clocks were turned on to the SCIA peripheral
    // in the InitSysCtrl() function

  SciaRegs.SCICCR.all =0x0007;   // 1 stop bit,  No loopback
                                   // No parity,8 char bits,
                                   // async mode, idle-line protocol
 SciaRegs.SCICTL1.all =0x0003;  // enable TX, RX, internal SCICLK,
                                   // Disable RX ERR, SLEEP, TXWAKE
 SciaRegs.SCICTL2.all =0x0003;
 SciaRegs.SCICTL2.bit.TXINTENA =1;
 SciaRegs.SCICTL2.bit.RXBKINTENA =1;
 #if (CPU_FRQ_150MHZ)
       SciaRegs.SCIHBAUD    =0x0001;  // 9600 baud @LSPCLK = 37.5MHz.
       SciaRegs.SCILBAUD    =0x00E7;
 #endif
 #if (CPU_FRQ_100MHZ)
      SciaRegs.SCIHBAUD    =0x0001;  // 9600 baud @LSPCLK = 20MHz.
      SciaRegs.SCILBAUD    =0x0044;
 #endif
 SciaRegs.SCICTL1.all =0x0023;  // Relinquish SCI from Reset
}

void scia_xmit(int a)
{
    while (SciaRegs.SCIFFTX.bit.TXFFST != 0) {}
    SciaRegs.SCITXBUF=a;

}

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

void scia_fifo_init()
{
    SciaRegs.SCIFFTX.all=0xE040;
    SciaRegs.SCIFFRX.all=0x204f;
    SciaRegs.SCIFFCT.all=0x0;

}

 

 

look for your reply 3q

  • Hi Xiaoxue,

    First you can try changing that statement to while(SciaRegs.SCIFFRX.bit.RXFFST ==0) { }. This should keep looping if it doesnt see any data on the line.

    If this doesnt work, you should scope the RX line to see that data is actually being sent across by the PC at the correct baud rate. I have also

    noticed that some USB to Serial converters dont work particularly well.

    Its probably hard to find a pc with a serial port these days but if you can try the serial connection on a Db9 to DB9 cable.

  • When your PC is stuck in while(SciaRegs.SCIFFRX.bit.RXFFST !=1) { }, what were the contents of SciaRegs.SCIFFRX.bit.RXFFST register? It would remain in an infinite loop even if SciaRegs.SCIFFRX.bit.RXFFSTregister = 2 (or) 3. Where it has actually received the transmitted contents but still CPU is in an infinite loop.

    -Manoj

  • Hi vishal

     

    3q very much for your reply.

    1.I did have changed the statement to

    while(SciaRegs.SCIFFRX.bit.RXFFST ==0)

    and even test the follow code(disable FIFO)

    //scia_fifo_init()

    while(SciaRegs.SCICTL2.bit.RXRDY ==0)

    but the SciaRegs.SCIFFRX.bit.RXFFST or  SciaRegs.SCICTL2.bit.RXRDY  is 0 not other numbers.

    2. I  scoped the TX and RX by oscillograph  today.

    for sci_echoback:

    TX send data to PC, hyperterminal could recive greeting words such as"Hello world", and oscillogrpah could see line change.

    RX receive data frome PC, hyperteminal or oscillograph have no change, means does't receive any data.

    for sci_looback_interrupts

    I disable the loopback register, change the code to

    //SciaRegs.SCICCR.bit.LOOPBKENA=1;

    //ScibRegs.SCICCR.bit.LOOPBKENA=1;

    but connect the SCIA-RX to SCIA-TX  and SCIB-RX to SCIB-TX by jumper wire.

    I want check if the SCI function could be work and scope the TX RX singal.

    This time everything is OK, i can stop at the ISR-RX, and the RX have singal received.

    so next I change the jumper wire as follow SCIA-TX to SCIB-RX        SCIA-RX to SCIB-TX

    i want to see if RX could receive data frome other deives(such as different sci port or other 28335 scia or LM39B90 scia)

    but this time I can't get into the ISR-RX(scia or scib). and the oscillograph can't receive any singal by TX or RX.

    3 fianlly i want to know the 28335 J3 function?

    look for your reply thank you

  • hi manoj

     

    first thankyou for your reply

    I did test the code as you said, but it does't work.

    don't konw the reason.

    SCIFFRX.bit.RXFFSTregister =0 every time.

  • XiaxueJing,

    As Vishal pointed out this could be hardware setup issue rather than firmware issue. How are you connecting your PC to SCI module in DSP? We don't provide UART port (DB-9 connector) in docking station.

    Regards,

    Manoj

  • Hi!

    I have the same issue with a docking station and control card with F28069. I added some test variables in the code, and I can see the code is executed once, but I cannot see anything with hyperterminal. I suppose, the execution doesn't continue, coz the processor doesn't receive anything from the PC. How can I connect to the SCI? I guess the USB port is used by Code Composer. I've tried also to start the program from Code Composer, then close it and start hyperterminal. I thought FTDI makes the convertion serial  to USB (I've populated the J9 jumper to connect RX to FTDI).

    Can you tell me what should I do?

    Thank you,

    Monica

  • I have a similar problem with the receiver of the SCI:

    I am using a TMS320F28027, and the SCI has been programmed to work at 19200 baud/sec.

    I have disabled FIFOs (Not like FIFO, I do not need them for this system).

    My system is stand alone, run from Flash.

    The link between the TMS320F28027 and the host, is direct, just from the pins of the TMS320F28027, to a level-shift (MAX232), and to the COM1 of the PC.

    So there it is not any responsibility on RS232-USB translation.

    Normally, It goes very well:

    1.-> If at the UART  comes a byte, then bit :[SciaRegs.SCIFFRX.bit.RXFFST]           goes to '1'.

    2.-> Then, if I see this bit, I can read the incoming byte (SciaRegs.SCIRXBUF.all) and so, bit   [SciaRegs.SCIFFRX.bit.RXFFST] goes to '0'.

    And so, the UART get ready for next incoming Byte.

    But if I am late in going to see the [SciaRegs.SCIFFRX.bit.RXFFST]  bit  and A SECOND BYTE INCOME TO THE UART, then UART does never  again work on receive.

    Exactly, if after a Byte has come, a second Byte comes BEFORE I see bit [SciaRegs.SCIFFRX.bit.RXFFST] , and read Byte SciaRegs.SCIRXBUF.all,,,,,,,,,,,,,,

    Then, bit  [SciaRegs.SCIFFRX.bit.RXFFST always is '0' and never change when comes a new Byte.

    I am developing a remote system, so this is the worst case.

    The Software still works, so the watch-dog does not reset the system, and still, the transmision part of the uart still works.

    But my system never more answer.

    The worst case (systems about 40 Kilometers from offices with nobody there).

    I have tried to find some 'recovery subroutine' for the UART, and can not find it.

    still, I have 're-initiate the SCI (Like in the start), and does not work.

    ¿Some help?

    Please, answer by this forum, my e-mail is getting bad.

    Thanks.

  • Well, work is work.

    I have solved the problem, and I think would be usefull for others.

    [SciaRegs.SCIFFRX.bit.RXFFST]  IS NOT a BIT.

    They are 5 bits, exactly, bit 12:8 of SCIFFRX.

    When no one Byte has come to the UART, and no one has read the UART, it is 0.

    When  1          Byte has come to the UART, and no one has read the UART, it is 1.

    When  2          Byte has come to the UART, and no one has read the UART, it is 2.

    etc....

    So , the 'test' that all the Texas Propose:   while(SciaRegs.SCIFFRX.bit.RXFFST != 1)

    is not a god propose.

    When JUST one Byte comes, yes, [SciaRegs.SCIFFRX.bit.RXFFST]  = 1, and so, the test works.

    But if other Byte Comes BEFORE being read the first, son [SciaRegs.SCIFFRX.bit.RXFFST] = 2, and the proposed test, fails.

    ¿Solutions?, easy.

    Change the test to   : if(SciaRegs.SCIFFRX.bit.RXFFST  > 0)

    Now, you test if AT LEAST, ONE BYTE HAS COME to the uart.

    O my god, how easy are things when you got them.¡¡¡¡¡

    Chers.

    Javier.

    Madrid.

    Spain.