• 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 Bluetooth® Low Energy & ANT Forum » CC2540 USB problems
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

CC2540 USB problems

CC2540 USB problems

This question is answered
Christian Brandt
Posted by Christian Brandt
on May 06 2011 02:24 AM
Prodigy130 points

Hi,

I am working with the CC2540DK-MINI kit but are having some problems with USB. We have created own hardware from the schematics from the USB dongle and when I flash the included "cc2540_ble1.0_master_usb_dongle.hex" the USB pops up on the PC and I can install the driver. But when I compile my own SW it only pops up as "USB Device Not Recognized". The same is the case if I flash the USB dongle with a sw I have compiled.

I have used the "SimpleBLEPeripheral" project and created a new group "CC2540USB" next to "CC2540EB" under HAL/Target and excluded the "CC2540EB" from the build. Then I have modified the include directories to match the USB target. When I compile this I get the following linker error:

Error[e27]: Entry "HalUARTRx::?relay" in module _hal_uart_usb (cc2540_ble\BLE-CC2540\Projects\ble\SimpleBLEPeripheral\CC2540DB\CC2540DK-MINI Keyfob Slave\Obj\_hal_uart_usb.r51 ) redefined in module hal_uart ( cc2540_ble\BLE-CC2540\Projects\ble\SimpleBLEPeripheral\CC2540DB\CC2540DK-MINI Keyfob Slave\Obj\hal_uart.r51 ) 

However, if I make a build using EB instead of USB the build is ok. And if I then switch back to USB, this is also compiled ok, but the USB device is not recognized. 
What am I doing wrong? Please help.
Best regards
Christian

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Willis1
    Posted by Willis1
    on May 06 2011 18:57 PM
    Expert8165 points

    Have you initialized the UART interface (it's actually a virtual UART, but the HAL initialization is the same). You can do that by adding this code to your application initialization function:

      // configure UART
      uartConfig.configured           = TRUE;
      uartConfig.baudRate             = HAL_UART_BR_115200;
      uartConfig.flowControl          = TRUE;
      uartConfig.flowControlThreshold = 48;
      uartConfig.rx.maxBufSize        = 128;
      uartConfig.tx.maxBufSize        = 128;
      uartConfig.idleTimeout          = 6;
      uartConfig.intEnable            = TRUE;
      uartConfig.callBackFunc         = myCBfunction;

      // start UART
      // Note: Assumes no issue opening UART port.
      (void)HalUARTOpen( HCI_UART_PORT, &uartConfig );

    You will also need to define a callback function (in the example above it is called myCBfunction) of halUARTCBack_t.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Christian Brandt
    Posted by Christian Brandt
    on May 09 2011 04:36 AM
    Prodigy130 points

    Willis
    Have you initialized the UART interface

    No, but now I have. However, this did not change anything.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • iR
    Posted by iR
    on Jul 22 2011 20:59 PM
    Intellectual590 points

    Hi Christian,

    I'm having the same problem, did you find a solution?

    Regards,
    iR 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • iR
    Posted by iR
    on Jul 26 2011 18:30 PM
    Verified Answer
    Verified by Willis1
    Intellectual590 points

    Hello,

    In case anyone else comes across this problem my solution was simple.  I had misread a filename and ended up including a source file twice in the project and hence the redefinition error.

    So, to fix the problem, audit your project files to find the culprit.  The quickest and smartest way to do this is to search (a simple ctrl+shift+f should do the trick) for the name of the entry given in the error message and, hopefully, the results will be from a single file and this have been included more than once in the project.

    A little embarrassing... :)  but I hope this helps.

    iR. 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Martin Romero
    Posted by Martin Romero
    on Aug 01 2011 06:59 AM
    Intellectual325 points

    Hi!
    Regarding the callback function "myCBfunction". How can i do it?. I followed all the steps to configure the usb, but when connecting the pc does not recognize the device, what can it be?

    For this project I relied on the SimpleBLEPeripheral, and I used the single-chip library.

    thanks...

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Seso
    Posted by Seso
    on Jan 13 2012 08:50 AM
    Prodigy140 points

    I also need help with these things... If someone successfuly uses USB with SimpleBLEPeripheral..

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jinkang Cen
    Posted by Jinkang Cen
    on Apr 10 2012 16:31 PM
    Intellectual430 points

    Maybe you could try excluding the _hal_uart_usb.c file from the project. When I did that, the error[e27] was gone!! It seems this problem could be solved by this way.

    Yet I am working on CC2531 USB dongle, but not the one you did. So I am not sure if it will work for you. Another thing I am not sure is that if this setting would influence the functionality of the dongle. 

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Chris Smowton
    Posted by Chris Smowton
    on Apr 10 2012 19:59 PM
    Prodigy30 points

    Hey all,

    I found that to get this setup to work I needed to use ble_single_chip_slave_pm_off.lib rather than ble_single_chip_slave_pm_on.lib as BLESimplePeripheral does by default. Otherwise the device went into an infinite loop during LL_Init and eventually the USB host tired of waiting for the peripheral to be ready and gave a "USB device not recognized" error.

    Chris

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Eng351
    Posted by Eng351
    on Apr 10 2012 21:28 PM
    Expert2980 points

    I have USB running well on simpleBLEperipheral using ble_single_chip_slave_pm_on.lib. It emulates an ftdi device and works with the driver.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Daniel A.
    Posted by Daniel A.
    on Jun 01 2012 18:16 PM
    Intellectual370 points

    Hi Eng,

    Could you please tell me how to get that? I can get it to compile but shows up as unregognized device on my PC :(

    Thanks a lot

    Daniel

    PS, I asked the same thing here because didn't read this post before.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Daniel A.
    Posted by Daniel A.
    on Jun 02 2012 11:44 AM
    Intellectual370 points

    I really can't get it working properly.

    The only way I can get the virtual serial port working is by undefining POWER_SAVING and by calling HalUARTOpen in my init function.

    However if I remove the initial call to HalUARTOpen and call it later in the code (pe, after a key press) it won't work. The workaround is to connect the pullup after a key press and it will work.

    If I define POWER_SAVING, there's no way for me to make it work even though I call "osal_pwrmgr_device( PWRMGR_ALWAYS_ON );" before enabling the pullup.

    I want to make a device which will be powered from a battery but when the USB is plugged it should enumerate a virtual com port to communicate with a PC but I can't get it to work and don't know if it's a limitation of the stack or I'm missing something.

    BTW, I'm linking to CC2540_ble_single_chip_peri.lib and the base project is the SimpleBLEPeripheral.

    Regards and many thanks in advance.

    Daniel

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Eng351
    Posted by Eng351
    on Jun 05 2012 04:42 AM
    Expert2980 points

    Do you have a means of detecting USB connection and removal i.e. an I/O interrupt port?

    On each connect your code should take the pull up high & call the USB init.

    On each disconnect your code should take the pull up low.

    Once the pull-up goes high that is signalling the PC that the device is ready for communication. If the init & process are not called quickly enough the PC will time out and show an error.

    There should also be a de-bouncing timer so that the pullup and init does not fire repeatedly when plugging in.

    As for the power management - have you checked in debug to see if your device is still going to sleep when USB is connected? osal_pwrmgr_device( PWRMGR_ALWAYS_ON ) should stop it going to sleep

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Daniel A.
    Posted by Daniel A.
    on Jun 05 2012 05:13 AM
    Intellectual370 points

    Hi Eng, thanks!

    It works if I do the following:

    1. Call osal_pwrmgr_device( PWRMGR_ALWAYS_ON ) from the Init function
    2. Launch a Timer from the init function
    3. When the Timer expires, I take the pull-up high and call the USB Init function from the message processing function

    However if I do the following, it won't work:

    1. Launch a Timer from the init function
    2. Call osal_pwrmgr_device( PWRMGR_ALWAYS_ON ) from the Init function
    3. When the Timer expires, I take the pull-up high and call the USB Init function from the message processing function

    I have tried to introduce several delays between points 2 and 3 in the second scenario but it won't work either.

    This is what the Documentation says about the osal_pwrmgr_device:

    This function is called on power- up or whenever the power requirements change (ex. Battery backed coordinator).  
    This function sets the overall ON/OFF State of the device’s power manager.  This function should be called from a
    central controlling entity (like ZDO).

    I got no clue about what a central controlling entity or ZDO is but I guess that it might be failing because of calling that function when the timer expires?

    As for the debugger thing, I'm using Windows Vista and it's a real pain to debug since it gets stalled over and over (not sure if it's a windows issue since it's my first time with the CC Debugger) and I can't follow the flow properly :(

    Regards

    Daniel

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Eng351
    Posted by Eng351
    on Jun 05 2012 05:30 AM
    Expert2980 points

    I also use vista & have no problems running the debugger. Have you tried it with compiler optimisation off and watchdog timer disabled? It is well worth it, it will make development much easier.

    Have you examined the code behind osal_pwrmgr_device()? All it does is set a flag which gets examined inside osal_pwrmgr_powerconserve(). If it is set to PWRMGR_BATTERY osal_pwrmgr_device() will check if all tasks have finished processing and enter sleep mode if this is the case.

    The two scenarios above should give the same outcome so I think something else is causing it to fail.

    Why do you use a timer to trigger the USB init? osal_pwrmgr_device( ) sets the flag instantly so this will make no difference. 

    Do you call the USB Event processing function in the main loop regularly enough?



    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Daniel A.
    Posted by Daniel A.
    on Jun 09 2012 10:38 AM
    Intellectual370 points

    Looks like I got it working now. The problem was that the HalUartInit function was called by the init function and that enabled the pullup so when I enabled it afterwards, nothing happened. 

    However the debug process is not still smooth and I can't turn the optimizations off because I get the following error:

    Error[e16]: Segment BLENV_ADDRESS_SPACE (size: 0x1000 align: 0) is too long for segment definition. At least 0x1000 more bytes needed. The problem occurred while processing the segment placement command 

    "-Z(CODE)BLENV_ADDRESS_SPACE=_BLENV_ADDRESS_SPACE_START-_BLENV_ADDRESS_SPACE_END", where at the moment of placement the available memory ranges were "-none-"
    Reserved ranges relevant to this placement:

    Should I modify the linker script or that's because I ran out of memory? This project is a modification of the SimpleBLEPeripheral plus the USB uart stuff.

    Regards!

    Daniel

    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