• 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 HCI over UART0 using CC2540EB build.
Share
Low Power RF & Wireless Connectivity
  • Forums
  • Announcements
  • Files
  • E2E Wiki
Options
  • Subscribe via RSS

Forums

CC2540 HCI over UART0 using CC2540EB build.

This question is not answered
Ed Tyrrell
Posted by Ed Tyrrell
on Jun 15 2011 11:04 AM
Prodigy60 points

 

Hello, 

I have managed to get both the HostTestRelease (via USB) and the SimpleBLEPeripheral compliling, working, and communicating between the two devices using BTool no problem. What I'd like to do now is redirect the HCI communication (on HostTestRelease side) with BTool, from USB to serial (UART0). It looks like in the build if I associate CC2540EB directory with the build instead of the default CC2540USB, it should use the UART instead of USB for HCI coms to BTool - is this correct? 

If not what is the best solution and suggested way forward? 

 

If I and correct, then am I missing a define somewhere? Any information would be a help.

Also if it is possible to use HCI over UART; 

Where is the baud rate set, parity, stop bits etc (defaults?),

Should the code for HCI-over-serial use the DMA option or ISR (which one is it built for)? 

BYW, the reason for wanting HCI over serial (UART) is our next stage in embedding the CC2540 into a non-USB platform; and spying BTool when necessary would be an advantage.

 

Thanks in advance,

Edward

UART CC2540 BLE 8051 HCI cc2540 uart CC2540 Serial interface
Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Fabien Gaubert1
    Posted by Fabien Gaubert1
    on Apr 26 2012 09:55 AM
    Intellectual460 points

    Hello,

    I'm trying to make the CC2540 Dongle communicate via USART with a Stellaris MCU, and it doesn't work for now.

    Is hardware (RTS/CTS) flow control mandatory? I only use TX/RX. Sorry if this is a newbie question, I never used RTS/CTS before.

    Thank you!

    CC2540 Stellaris
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Chris Norris
    Posted by Chris Norris
    on Apr 26 2012 15:12 PM
    Intellectual695 points
    Hi Fabien,
    I've been attempting to use the CC2540 UART without CTS and RTS, so I'm in a similar situation.  I found that modifications to HAL code are needed.

    On the CC2540, are you using the UART for your own data, or are you using the network processor configuration where the UART carries the HCI protocol?
     
    If you're using the port for your own data, you must create a halUARTCfg_t structure before you call HalUARTOpen().  Disable flow control with the following code:
      halUARTCfg_t uartConfig;
    uartConfig.flowControl = FALSE;
    
    
    When using TI's BLE stack in the network processor configuration, it appears that HalUARTOpen() is called from within the stack.  In the network processor configuration,  The halUARTCfg_t reference passed to HalUARTOpen() determines whether flow control is enabled or disabled. 
    Stepping through the code, it is possible to modify the halUARTCfg_t settings before the HAL code actually configures the port.  If you're using TI's V1.2 stack for BLE, you can modify HalUARTOpenDMA() in _hal_uart_dma.c to disable CTS/RTS.

    Add the following line to the beginning of the open function:
    static void HalUARTOpenDMA(halUARTCfg_t *config)
    {
    config->flowControl = HAL_UART_FLOW_OFF;
    Note that if you need to change the baud rate, this is a good place to add that code too.

    I noticed that when the DMA version of the HAL UART driver is used, the RTS line is controlled in software. Comment out the following lines to prevent the toggle of RTS.

    In HalUARTReadDMA(), comment out the following line:
    // PxOUT &= ~HAL_UART_Px_RTS; // Re-enable the flow on any read.

    In HalUARTPollDMA(), comment out the following line:
    // PxOUT |= HAL_UART_Px_RTS;
    There may be other steps to configure the CTS and RTS port pins back to general I/O, but I haven't gotten that far.
    Hope this helps!
    HAL UART DMA CTS RTS
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Fabien Gaubert1
    Posted by Fabien Gaubert1
    on Apr 27 2012 03:54 AM
    Intellectual460 points

    Hi Chris,

    Thank you for answering.
    I am using HostTestRelease, which uses the network processor configuration, and, I think, USART 0 on pins P0_2 and P0_3.

    I added, as you said, config->flowControl = HAL_UART_FLOW_OFF in HalUARTOpenDMA, but it doesn't change anything. I commented PxOUT &= ~HAL_UART_Px_RTS and PxOUT |= HAL_UART_Px_RTS but I think this is not necessary, as this is only an output (the system dosn't block waiting for acknowledgment).

    On the Stellaris side (MCU communicating with the CC2540 dongle), I configured USART as following:

    ROM_UARTConfigSetExpClk(UART4_BASE, ROM_SysCtlClockGet(), 57600,
    (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE |
    UART_CONFIG_PAR_NONE));

    On the MCU side, USART is working properly (I wired RX and TX just to try sending and receiving, and it works properly).

    Then I wired the MCU to the USB dongle, and send a device init message as follow:

        unsigned char outputBuffer[] = {0x01, 0x00, 0xFE, 0x26, 0x08, 0x05, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
        0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00};
        BLESend((unsigned char *)outputBuffer, 42);
    //*****************************************************************************
    //
    // Send data to the BLE Dongle, using PJ1 (USART 4 TX)
    //
    //*****************************************************************************
    void BLESend(const unsigned char *pucBuffer, unsigned long ulCount)
    {
        //
        // Loop while there are more characters to send.
        //
        while(ulCount--)
        {
            //
            // Write the next character to the UART.
            //
            ROM_UARTCharPutNonBlocking(UART4_BASE, *pucBuffer++);
        }
        UARTprintf("BLE send\n");
    }
    UARTCharPutNonBlocking prototype is extern tBoolean UARTCharPutNonBlocking(unsigned long ulBase, unsigned char ucData); so apparently, this isn't a problem of conversion (always unsigned char).
    The CC2540 receive serial messages (a breakpoint stops inside HalUARTReadDMA(uint8 *buf, uint16 len) when MCU sends device init message) but the value of *buff in HalUARTReadDMA (...) doesn't seems to be good. And the CC2540 doesn't send anything back.
    I also tried sending messages from the cc2540 to the MCU directly, by calling HalUARTWriteDMA and it works properly.
    Two full days I'm on  this...
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Fabien Gaubert1
    Posted by Fabien Gaubert1
    on Apr 27 2012 04:53 AM
    Intellectual460 points

    Ok, this is WORKING!

    ROM_UARTCharPutNonBlocking was a huge mistake. I obviously need to use a blocking function.

    config->flowControl = HAL_UART_FLOW_OFF is also needed, as Chris said.

    Thank you!

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Chris Norris
    Posted by Chris Norris
    on Apr 27 2012 13:23 PM
    Intellectual695 points

    Hi Fabien,

    I'm glad you got it working.

    Note that if you want to increase or decrease baud rates, you can add the line

    config->baudRate = HAL_UART_BR_115200
    in the same location where you modified the flow control.

    With regards to commenting out the PxOUT assignment that control RTS, if you are not needing that pin for something else, then you are correct that leaving it enabled does not affect the functionality.  You would only need to comment that out if you want to reassign that port pin for a different I/O function unrelated to the UART.

    Enjoy the weekend!

    Chris Norris

    HAL UART
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Fabien Gaubert1
    Posted by Fabien Gaubert1
    on Apr 30 2012 04:30 AM
    Intellectual460 points

    Hi,

    Chris, thank you for your answer.

    I have another question about RTS. I am studying the code but I don't know enough about DMA and the CC2540 to find an anser for now.

    Is PxOUT line only a hardware control, or is it also used for higher level information?

    I explain myself:

    On the MCU side, I receive  messages from the CC2540, but most of them are cut in several parts, which makes my life really complicated to retrieve information (is it a new message, is it the previous one going?). Which brings me to this question: How can I know a message is over, and a new one is beginning? Is it the purpose of RTS/CTS control?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Fabien Gaubert1
    Posted by Fabien Gaubert1
    on Apr 30 2012 04:53 AM
    Intellectual460 points

    Ok, this was a really dumb question...

    CTS/RTS has nothing to do with this. On the contrary, data length field, in every message, may be related... :+). Sorry for that.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Chris Norris
    Posted by Chris Norris
    on Apr 30 2012 12:48 PM
    Intellectual695 points

    Hi Fabien,

    You are correct that the data length value will be key in keeping synchronized with the messages that you receive.  The data sent from the CC2540 to your MCU will be HCI event packets.  Most (not all) of the event packets contain Texas Instruments vendor-specific events.

    The first byte of an event packet is 0x4.  This value is HCI_EVENT_PACKET as defined in hci_controller.h.

    The second byte is the event code.  This is usually a Texas Instruments vendor-specific event, identified by the value 0xFF.  This value is HCI_VE_EVENT_CODE as defined in hci.h.

    For Texas Instruments vendor-specific events, the third byte is the data length.

    If you always test the above three bytes in the HCI events, you can locate the start of each new HCI event and detect if your receiver has gotten out of sync.


    I should mention one exception.  I have occasionally seen the CC2540 send some HCI events that are defined in the Bluetooth standard that are not the TI vendor-specific events.  The one I capture occasionally is HCI_COMMAND_COMPLETE_EVENT_CODE (0x0E) defined in hci.h.  This is why it is very important to test the second byte in every event, since the Bluetooth events you receive are not guaranteed to always be the TI vendor-specific event (0xFF).

    Regards,
    Chris

    HCI
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Jack Lam
    Posted by Jack Lam
    on Nov 08 2012 23:06 PM
    Prodigy70 points

    Hi Tyrell,

        I am using CC2540EB configuration for HostTestRelease. HCI over USB is working well with Btool, but it failed for HCI over UART. Is there any tricks?

    Thanks

    Jack Lam

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Aravinda P N
    Posted by Aravinda P N
    on Apr 29 2013 23:45 PM
    Prodigy140 points

    We are working on an application that requires us to control the PAN1720 BT module by sending HCI commands over UART. In an effort towards this we are trying to get the hex files that need to run on the BT modules that use this interface(physical UART).

    We are using the BLE v1.3 stack. The HostTestRelease project is being evaluated. When the CC2540USB configuration of this project is used and the hex files are generated and flashed on the PAN1720 EVM, then , upon connecting the EVM to the PC through USB, the PC recognizes the module as a virtual COM port( USB CDC device). When the Btool is run, we are able to see that the module is recognized and is able to scan the BT devices..

    We wanted to achieve similar functionality now over the physical UART(and not the virtual COM port through USB). For this, as mentioned in this thread,  we used the CC2540EM configuration of the HostTestRelease project(as against the CC2540USB configuration) and flashed the binaries on the PAN1720 EVM. We then connected the EVM to the PC through a RS232 to USB converter instead of directly connecting it through the USB (The EVM is powered up separately). In this case, however the BTool is not able to recognize the module on the serial port and thus we are not able to get the BT communication going.(We get a GAP device intialization failed error and none of the BTool widgets are activated).

    Could you kindly indicate what other changes needs to be done(in the configuration) so that we can get the UART communication to the modules working. Is the RTS/CTS mandatory(we do not have those connected in hardware). I also added the line to disable the flowcontrol in HweOpenDMA() but still there is no change. We tried both UART_0 and UART_1 modules of CC2540 (corresponding to HAL_UART_DMA = 1 or 2 respectively) but even then the module is not being recognized. We also see that the BLE v1.3 stack HostTestRelease has other configurations such as CC2540EM-EBL and  CC2540EM-SBL. What do these mean? Sould we use them?

    What we are looking for is for two hex files that run on the BT modules, one that can acccept HCI commands from the master(controller) over UART and transmit the data to another BT module (over BT) which in turn sends this data to another controller through UART again. We need this end to end communication working for which we would first need the two hex files. Could you kindly indicate what hex files(from the B:LE stack) could be used for such applications?Or what changes have to be done in the source codes contained in the BLE stack. Would the changes involve just configuration changes or does it require us to do few other modifications in the stack?

    Thanks in advance

    Aravinda

    CC2540 BLE stack UART PAN1720
    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Aravinda P N
    Posted by Aravinda P N
    on Apr 30 2013 01:34 AM
    Prodigy140 points

    We are working on an application that requires us to control the PAN1720 BT module by sending HCI commands over UART. In an effort towards this we are trying to get the hex files that need to run on the BT modules that use this interface(physical UART).

    We are using the BLE v1.3 stack. The HostTestRelease project is being evaluated. When the CC2540USB configuration of this project is used and the hex files are generated and flashed on the PAN1720 EVM, then , upon connecting the EVM to the PC through USB, the PC recognizes the module as a virtual COM port( USB CDC device). When the Btool is run, we are able to see that the module is recognized and is able to scan the BT devices..

    We wanted to achieve similar functionality now over the physical UART(and not the virtual COM port through USB). For this, as mentioned in this thread,  we used the CC2540EM configuration of the HostTestRelease project(as against the CC2540USB configuration) and flashed the binaries on the PAN1720 EVM. We then connected the EVM to the PC through a RS232 to USB converter instead of directly connecting it through the USB (The EVM is powered up separately). In this case, however the BTool is not able to recognize the module on the serial port and thus we are not able to get the BT communication going.(We get a GAP device intialization failed error and none of the BTool widgets are activated).

    Could you kindly indicate what other changes needs to be done(in the configuration) so that we can get the UART communication to the modules working. Is the RTS/CTS mandatory(we do not have those connected in hardware). I also added the line to disable the flowcontrol in HweOpenDMA() but still there is no change. We tried both UART_0 and UART_1 modules of CC2540 (corresponding to HAL_UART_DMA = 1 or 2 respectively) but even then the module is not being recognized. We also see that the BLE v1.3 stack HostTestRelease has other configurations such as CC2540EM-EBL and  CC2540EM-SBL. What do these mean? Sould we use them?

    What we are looking for is for two hex files that run on the BT modules, one that can acccept HCI commands from the master(controller) over UART and transmit the data to another BT module (over BT) which in turn sends this data to another controller through UART again. We need this end to end communication working for which we would first need the two hex files. Could you kindly indicate what hex files(from the B:LE stack) could be used for such applications?Or what changes have to be done in the source codes contained in the BLE stack. Would the changes involve just configuration changes or does it require us to do few other modifications in the stack?

    CC2540 BLE HostTestRelease PAN1720
    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