• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » C2000™ Microcontrollers » C2000 32-bit Microcontrollers Forum » sci_echoback example can't receive data from PC via SCI-A
Share
C2000™ Microcontrollers
  • Forums
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
C2000 Resources
  • Product Folder
  • C2000 Training Portal
  • C2000 Technical Training Catalog
  • C2000 Datasheets, App Notes, User Guides
  • C2000 Hardware Design Kits
  • controlSUITE for C2000 Software Library


  • InstaSPIN Resources
  • What is InstaSPIN?
  • Videos and Support


  • InstaSPIN-FOC and InstaSPIN-MOTION Resources
  • What is InstaSPIN-FOC?
  • What is InstaSPIN-MOTION?
  • Product Folder: F28069F, F28068F, F28062F, F28068M, F28069M
  • User’s Guide
  • Technical User’s Manual
  • Tools
  • Forums

    sci_echoback example can't receive data from PC via SCI-A

    This question is not answered
    collean
    Posted by collean
    on Oct 11 2011 01:00 AM
    Prodigy10 points

    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

    **************

    nomore sorrow

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Vishal_Coelho
      Posted by Vishal_Coelho
      on Oct 11 2011 12:03 PM
      Expert5755 points

      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.

      Regards,

      Vishal

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Manoj Santha Mohan
      Posted by Manoj Santha Mohan
      on Oct 11 2011 16:50 PM
      Expert6280 points

      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

      ---------------------------------------------------------------------------------------------------

      If a post answers your question, please mark it with the "verify answer" button.

      Other useful links:

      C2000 Getting Started   C2000 Flash Common Issues/FAQs   Emulation FAQ

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • collean
      Posted by collean
      on Oct 11 2011 19:27 PM
      Prodigy10 points

      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

      **************

      nomore sorrow

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • collean
      Posted by collean
      on Oct 11 2011 19:34 PM
      Prodigy10 points

      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.

      **************

      nomore sorrow

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Manoj Santha Mohan
      Posted by Manoj Santha Mohan
      on Oct 12 2011 12:34 PM
      Expert6280 points

      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

      ---------------------------------------------------------------------------------------------------

      If a post answers your question, please mark it with the "verify answer" button.

      Other useful links:

      C2000 Getting Started   C2000 Flash Common Issues/FAQs   Emulation FAQ

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Monica Zolog
      Posted by Monica Zolog
      on Nov 11 2011 08:11 AM
      Expert1520 points

      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

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Antonio Javier Morcillo y Martinez
      Posted by Antonio Javier Morcillo y Martinez
      on Apr 03 2013 11:35 AM
      Prodigy10 points

      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.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Antonio Javier Morcillo y Martinez
      Posted by Antonio Javier Morcillo y Martinez
      on Apr 04 2013 06:38 AM
      Prodigy10 points

      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.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use