• 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 » Low Power RF & Wireless Connectivity » Low Power RF Proprietary Software & SimpliciTI Forum » CC1111: Unloading USB FIFO Packets
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

Forums

CC1111: Unloading USB FIFO Packets

This question is answered
ReneK
Posted by ReneK
on Feb 25 2009 06:42 AM
Prodigy180 points

I ran into a problem with unloading OUT FIFO Packets. I can read the FIFO, but the first two bytes are always read as 0xBC and 0xAF, no matter of what I set them to (on the host). The remaing bytes are read correctly. I have a protocol analyzer at hand, so I can say for sure that there is no 0xBC or 0xAF travelling across the cable. What I do is this:

 

void Usb_ReadFifo(BYTE volatile xdata* pFifo, void* pBuffer, BYTE bSize)
{
    BYTE* pDest = pBuffer;

    for(; bSize; --bSize)
        *pDest++ = *pFifo;
}

 void HandleEp2Request()
{
    xdata BYTE         wdr[24];
    BYTE                  bIndex = USBINDEX;

    USBINDEX = 2;
   
    if(USBCSOL & USBCSOL_OUTPKT_RDY)
    {
        if((USBCNTH) || (USBCNTL != sizeof(wdr)) || (USBCSOL & USBCSOL_DATA_ERROR))
        {
            USBCSOL |= USBCSOL_FLUSH_PACKET;
        }
        else
        {
            Usb_ReadFifo(&USBF2, &wdr, sizeof(wdr));
            USBCSOL &= ~USBCSOL_OUTPKT_RDY;

            // here:

            // wdr[0] == 0xBC

            // wdr[1] == 0xAF

        }
    }

    USBINDEX = bIndex;
}

 

EP2 ist an interrupt OUT endpoint and USBMAXO ist set to 32. Any idea of what I am doing wrong?

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Glenn Fawcett
    Posted by Glenn Fawcett
    on Sep 02 2010 12:38 PM
    Prodigy95 points

    Sorry, my previous post had a typo: I wrote the hex value AA a total of 256 (not 255) times into USBF4. In fact, the first mystery byte in the received packet was the 256th byte written to the FIFO and the second mystery byte was the 255th byte written.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Glenn Fawcett
    Posted by Glenn Fawcett
    on Sep 08 2010 23:47 PM
    Verified Answer
    Verified by TIABO
    Prodigy95 points

    I've discovered the cause of the "first two bytes bad" behavior: it happens when the endpoint's USBMAXO register has a zero or illegal value. Likely causes of this are:

    1. USBMAXO was never set -- it defaults to zero.

    2. USBMAXO was loaded when USBINDEX was set to the wrong endpoint number.

    3. USBMAXO was set too early; an undocumented feature of the chip is that it resets USBMAXO and USBMAXI, along with all other FIFO registers, to zero when a bus reset occurs. It must be set to the correct value after every reset and before the FIFO is used. (An appropriate place to initialize the FIFOs is when a "Set Address" request is received and USBADDR is loaded with the address; this is guaranteed to be between every reset and first use of the FIFO.)

    4. USBMAXO was loaded with an illegal value -- note that it should be set to the largest expected message size (in bytes), plus seven, divided by eight. (The FIFO size becomes USBMAXO * 8 bytes.)

    CC2511 CC1111 USB FIFO OUT FIFO
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Nicolas PC
    Posted by Nicolas PC
    on Sep 09 2010 00:59 AM
    Prodigy70 points

    Thanks Glenn,

    It didn't occur to me that USBMAXI and USBMAXO could be reset along with USB bus reset. In my code these registers are set once for all in an init procedure. In fact I also overlooked the fact that USBCS* registers are reset too, which may explain some other issues I have with my code (double buffering would be disabled along with USB reset).

    The fact that USBMAXI/USBMAXO are reset in this way should really be written clearly in the datasheet under the "USB Reset" section.

    I will change my code today and keep you informed of the result.

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Nicolas PC
    Posted by Nicolas PC
    on Sep 09 2010 01:47 AM
    Prodigy70 points

    I have just finished testing my code modified to take into account the USB reset clearing USBMAXO, and I am glad to confirm that IT WORKS NOW!

    Thanks a lot for finding the issue.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Bjørn
    Posted by Bjørn
    on Sep 09 2010 06:53 AM
    Intellectual2470 points

     

    Hi,

    Good to hear that you found out of what is causing this problem. TI's USB software examples do not have the same problem since the USBMAXx registers are set in the USB setup transaction handler (as opposed to in initialization code). We recommend to use these examples for developing USB applications with CC1111/CC2511.

    We can confirm that the USBMAXx registers are among the registers that are cleared upon USB reset. This could be documented better in the datasheet, and we have noted it as a suggested improvement of this document.

    Regards,

    Bjørn

     

     

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Glenn Fawcett
    Posted by Glenn Fawcett
    on Sep 09 2010 13:15 PM
    Prodigy95 points

    Bjørn is correct; the example code initializes the FIFO (including USBMAXO) in the handler for the "Set Configuration" request which, along with "Set Address," is a mandatory request between every bus reset and first use of the FIFO.

    However, using the examples for developing USB applications will not be a viable option for most programmers. A reasonable implementation of a USB driver for the CC1111 or CC2511 (and other chips) is about 700 lines of C code (plus comments) in a 40K source file. A small header file will be needed for prototypes.

    In contrast, the TI example USB driver is spread across 33 C files and one assembler file, has 1960 lines of C code and 200 lines of assembler, and totals 278K of code. (Apparently, assembler was used because the author didn't know that the linker configuration file from IAR has an error that places const data in RAM.) The code is so obscure that I was only able to figure out what it was doing by single-stepping it in the debugger.

    I can't use the TI example as a model because I don't want to be fired for incompetence.

    CC2511 CC1111 USB FIFO
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Seb7734
    Posted by Seb7734
    on Sep 09 2010 13:46 PM
    Prodigy105 points

    Thank you for this discussion!!!!! It was a headache that two mysterious bytes...

    Finally it works on my code too.

    And yes, please, clarify this on the next datasheet update.

    Thank you again. :D

    Seb.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
12
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