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.

UART, Ext Micro and CC2541

Other Parts Discussed in Thread: CC2541, CC2540, CC2541DK-MINI

Hi, 

I tried to search forum as much as possible to search for the answers that I was looking for but I was unable to get any satisfactory answers. Lots of people have

asked the questions in the past that I am aksing in this post but they were were never answered properly.  Please be patient with me. 

I am trying to interface CC2541 to an external microcontroller using UART. 

External MCU -----> CC2541 ---------> wireless ---------> PC

My questions are as follows 

1. What formware should I use to do this? 

BLE_Bridge

HostTestRelease

SerialBLEbridge

SimpleBLEPeripheral

If someone recommends any of the given choices above then can also recommend what part of the code needs to be changed. What pins should be used to do the Rxd and TxD on CC2541?

2. What commands should the MCU used to make CC2541 adverstise, pair , transfer data to PC and read data from the PC. What commands should PC send to the CC2541 to accept the data and send it to an external MCU?

3. What kind of USB based bluetooth dongle should be used with the PC to connect with CC2541? Can any off the shelve USB based bluetooth dognle can work? 

dave

  • Hi,

    1) You can use HostTestRelease firmware on CC2541 if you are want to use HCI commands to communicate between the external Micro controller and CC2541. Regarding the pins for UART Rx and Tx, you need to refer to the pins brought out on the board that you are using(Keyfob, sensortag or any other board). You can check the connections by using any project like HostTestRelease or BLE_Bridge.

    2) The commands depends upon the firmware you use in CC2541. If HostTestRelease, use HCI commands. If BLE _bridge, use custom commands as explained in BLE_Bridge wiki.

    3) You can use a CC2540 USB dongle having HostTestRelease firmware burned to it.

    Regards,
    Arun
  • Hi, Thanks for your reply.

    1. I have opened the "HostTestRelease" project with IAR but it does not have configuration for UART. It has following configurations

    a) CC2541SPI
    b) CC2541EM
    c)CC2541EM-SBL
    d)CC2541EM-EBL
    e)CC2541SPI-SBL
    f) CC2541EM-EBL

    Which one you want me to use?

    2. You did not confirm that I can not use other off the shelve bluetooth dongle? Is this something that you can confirm, please?

    3. The thing is that the documents that TI engineers have written are not user friendly at all. It easier to understand these documents for someone if he/ she is working with bluetooth for at least three years but not for someone who just started. So, would you please give some simple to understand examples about the commands ( both HostTestRelease , BLE_Bridge and external MCU) instead of referring me to documents that will take months to understand.

    And I know it might not be a part of your job. But I request that if you do it then lots of people will not bother you on this forum for same things again and again .

    Thanks
    dave
  • Hi,

    1) The configuration of UART depends upon the CC2541 board that you are using. If you are using CC2541 EM(Evaluation Module), then you can use the CC2541 EM configuration. If you are using keyfob, then you need to edit the settings in _hal_uart_dma.c file. Similarly for sensorTag, you may be required to modify the uart settings in _hal_uart_dma.c file.

    2) Btool and BLE device monitor have been designed to work with CC2540USB dongle with HostTestRelease firmware. I don't know which application you can use with Off the self dongles.

    3) I understand the issues you are facing. But I suggest you start with TI_BLE_Software_Developer's_Guide.pdf to get an understanding of the BLE SDK. The you can look at TI_BLE_Vendor_Specific_HCI_Guide.pdf to understand the commands and events to use on external MCU to communicate with HostTestApp firmware running on CC2541.

    Regards,
    Arun
  • Hi,

    1. I am not using any of TI's developement kit. I am using the following product

    www.lsr.com/.../tiwi-ub1
    www.digikey.com/.../3539644

    2. Let's say that I configured the Host Test Release or SerialBLEBridge for UART. What fuctions in the code or what part of the code do I need to change to get what I want to do?

    3. I configured the Host Test Release software for CC2541EM and check the preprocessor.It says HAL_UART=TRUE. What would be the pin outs of the CC2541 for TxD and RxD with this configuration?

    Thanks
    Dave
  • Hi,

    This is concerning that if I want to develope a product using CC2541 then I have to use CC2540 USB Dongle to communicate with the PC. This is strange. The dongle does not even come in any kind of packaging and how much is it?

    dave
  • Hi Dave,

    The CC2540 USB dongle connected to PC is used as a BLE client. You can very well use your phone(BLE compatible) too for this purpose. Also any BLE dongle should suffice for that, although I don't know which software to use with these dongles.

    You can buy the USB dongle if you want from TI e-store www.ti.com/.../cc2540emk-usb

    Regards,
    Arun
  • Hi,

    1) But this Dongle is too expensive for the product developement . Off the shelve dongles go for like a dollar. I have to provide it with the product and it does not even come with any kind of casing.

    2) I am not using TI's development kit. I am using the following third party module. It is CC2541 based. its TiWi-uB1.

    www.lsr.com/.../330-0132.pdf

    www.digikey.com/.../3539644

    So, what should be the configuration
    a) CC2541SPI
    b) CC2541EM
    c)CC2541EM-SBL
    d)CC2541EM-EBL
    e)CC2541SPI-SBL
    f) CC2541EM-EBL

    Regards,
    dave
  • Hi,
    I am not using any TI's developement kit. I am using the following TiWi-ub1 unit. It is CC2541 based . So what should be my configuration settings
    www.lsr.com/.../330-0132.pdf

    a) CC2541SPI
    b) CC2541EM
    c)CC2541EM-SBL
    d)CC2541EM-EBL
    e)CC2541SPI-SBL
    f) CC2541EM-EBL

    Thanks
    dave
  • Hi,

    The thing is that from the product developement point of view. The TI's dongle is very much expensive. There are dongles available for a dollar. Plus this dongle does not even come with any kind of packaging. I wonder what and how CC2541 needs to be programmed to talk to ordinary bluetooth dongle.

    dave
  • Hi,

    1) You can use Off the shelve dongles too as a BLE client.

    2) I don't have experience in TiWi-uB1 development kit. But I believe you should be using the CC2541EM configuration which uses UART. You need to check documentation that comes with the TiWi-uB1 development kit.

    Regards,
    Arun
  • Hi, thanks for your reply. I programmed the CC2541 with the HostTestRelease firmware with "CC2541EM" configuration and tried to connect it to BTool . I got the following messages . Any advise about what is going on here! It seems like that the BTool was unable to connect to the CC2541.

    One more thing, I looked for some documentation about writing the HCI commands using BTool but unable to find any. Can you direct me to one? For example how you send data to the CC2541 and read it back.

    Best, Dave

    [57] : <Rx> - 06:56:24.124
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x13 (19) bytes(s)
    Event : 0x0605 (GAP_EstablishLink)
    Status : 0x00 (Success)
    DevAddrType : 0x00 (Public)
    DevAddr : 60:03:08:D7:C3:A0
    ConnHandle : 0x0000 (0)
    ConnInterval : 0x0050 (80)
    ConnLatency : 0x0000 (0)
    ConnTimeout : 0x07D0 (2000)
    Clock Accuracy : 0x00 (0)
    Dump(Rx):
    04 FF 13 05 06 00 00 A0 C3 D7 08 03 60 00 00 50
    00 00 00 D0 07 00
    ------------------------------------------------------------------------------------------------------------------------
    [58] : <Rx> - 06:56:25.904
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x0A (10) bytes(s)
    Event : 0x0580 (GATT_ClientCharCfgUpdated)
    Status : 0x00 (Success)
    ConnHandle : 0x0000 (0)
    PduLen : 0x04 (4)
    AttrHandle : 0x000F (15)
    Value : 0x02 (2)
    Dump(Rx):
    04 FF 0A 80 05 00 00 00 04 0F 00 02 00
    ------------------------------------------------------------------------------------------------------------------------
    [59] : <Info> - 06:56:33.297
    Device Disconnected
    Handle = 0x0000
    Addr Type = 0x00 (Public)
    BDAddr = 60:03:08:D7:C3:A0
    ------------------------------------------------------------------------------------------------------------------------
    [60] : <Rx> - 06:56:33.297
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x0606 (GAP_TerminateLink)
    Status : 0x00 (Success)
    ConnHandle : 0x0000 (0)
    Reason : 0x13 (Peer Requested)
    Dump(Rx):
    04 FF 06 06 06 00 00 00 13
    ------------------------------------------------------------------------------------------------------------------------
  • Hi,

    I thought you were trying to use an external MCU to send HCI commands to CC2541 (running HostTestRelease).

    Anyway, now since you have connected Btool to your CC2541, the Btool application emulates the role of External MCU which you wanted.

    So the moment you open up Btool, you will initiate a GAP_DeviceInit call which will responded by an Acknowledgement and response. I believe that is happening for you. Also I see that your GAP_EstablishLink request has been responded by success. Later the peer requested a disconnection(probaly because you tried accessing attributes without authenticating) and hence you disconnected. SO you were able to connect to Peer device and and later disconnected. So your configuration of CC2541 EM board is fine.

    Now regarding the sequence of steps to use HCI commands, I would advise you to check out the steps followed by BTool from start up to connection, read and writing of characteristics.

    Please have a look at the following link where there is a sample python script for you to understand the code flow when using HCI commands.

    github.com/.../BLE_HCI

    Regards,
    Arun
  • Hi,
    Thanks for your reply. I changed the plan. I am using HOSTtest Release software and using BTool to understand the HCI commands first. Then I will try to implement the commands into my external microcontroller code and talk to CC2541 based bluetooth module.

    I did not know that Btool was connected to the module and then also got disconnected. Would you advise how can I keep them connected and try to learn about HCI commands. How can I write to the bluetooth module using BTool and Read back from it. Plsu where can I find user manual for BTool or some other detailed document. Plus I am looking for some detailed easy to understand HCI command document.

    Thanks
    dave
  • Hi,

    Once you establish a link it should remain connected untill you disconnect it or if authentication fails or if peer requests it. What is the peer device that you are connecting to? It depends upon what services the peer device allow.

    I suggest you download the BL ESDK v1.40 and check the documents under the <Installation_path>documents folder. That should give you a brief idea about BLE commands to use and the software architecture.

    www.ti.com/.../ble-stack

    Regards,
    Arun
  • I programmed the CC2541 with "Host Test Release" and tried to connect to it using Btool. I did scaning and then tried to established the connection. I Pressed " Establish" button.What BTool did I pasted below.

    What do you mean by peer device? The bluetooth dongle is from TI. I am just trying to connect CC2541 to PC using your's bluetooth dongle and try to see HCI commands using BTool. I think it s not connecting at all.


    1] : <Tx> - 03:45:25.125
    -Type : 0x01 (Command)
    -Opcode : 0xFE09 (GAP_EstablishLinkRequest)
    -Data Length : 0x09 (9) byte(s)
    HighDutyCycle : 0x00 (Disable)
    WhiteList : 0x00 (Disable)
    AddrTypePeer : 0x00 (Public)
    PeerAddr : A0:C3:D7:08:03:60
    Dump(Tx):
    01 09 FE 09 00 00 00 A0 C3 D7 08 03 60
    ------------------------------------------------------------------------------------------------------------------------
    [2] : <Rx> - 03:45:25.172
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x067F (GAP_HCI_ExtentionCommandStatus)
    Status : 0x00 (Success)
    OpCode : 0xFE09 (GAP_EstablishLinkRequest)
    DataLength : 0x00 (0)
    Dump(Rx):
    04 FF 06 7F 06 00 09 FE 00
    ------------------------------------------------------------------------------------------------------------------------
    [3] : <Info> - 03:45:25.399
    Device Connected
    Handle = 0x0000
    Addr Type = 0x00 (Public)
    BDAddr = 60:03:08:D7:C3:A0
    ------------------------------------------------------------------------------------------------------------------------
    [4] : <Rx> - 03:45:25.394
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x13 (19) bytes(s)
    Event : 0x0605 (GAP_EstablishLink)
    Status : 0x00 (Success)
    DevAddrType : 0x00 (Public)
    DevAddr : 60:03:08:D7:C3:A0
    ConnHandle : 0x0000 (0)
    ConnInterval : 0x0050 (80)
    ConnLatency : 0x005C (92)
    ConnTimeout : 0x0A54 (2644)
    ClockAccuracy : 0x00 (0)
    Dump(Rx):
    04 FF 13 05 06 00 00 A0 C3 D7 08 03 60 00 00 50
    00 5C 00 54 0A 00
    ------------------------------------------------------------------------------------------------------------------------
    [5] : <Rx> - 03:45:27.024
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x0A (10) bytes(s)
    Event : 0x0580 (GATT_ClientCharCfgUpdated)
    Status : 0x00 (Success)
    ConnHandle : 0x0000 (0)
    PduLen : 0x04 (4)
    AttrHandle : 0x000F (15)
    Value : 0x02 (2)
    Dump(Rx):
    04 FF 0A 80 05 00 00 00 04 0F 00 02 00
    ------------------------------------------------------------------------------------------------------------------------
    [6] : <Info> - 03:45:37.226
    Device Disconnected
    Handle = 0x0000
    Addr Type = 0x00 (Public)
    BDAddr = 60:03:08:D7:C3:A0
    ------------------------------------------------------------------------------------------------------------------------
    [7] : <Rx> - 03:45:37.226
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x0606 (GAP_TerminateLink)
    Status : 0x00 (Success)
    ConnHandle : 0x0000 (0)
    Reason : 0x13 (Peer Requested)
    Dump(Rx):
    04 FF 06 06 06 00 00 00 13
    ------------------------------------------------------------------------------------------------------------------------
  • Hi,

    Ok. I am little bit confused now. How did you connect the CC2541 to PC? using UART?

    Or are you using a CC2540USB dongle to connect to PC(which runs Btool)? and then trying to connect to CC2541 over BLE connection.

    Please note that CC2541 running HostTestRelease is running in dual chip mode and needs a Host chip to control it. It will not start advertising on its own unless the exact command is given by the Host MCU.

    I believe you are connecting(over BLE) to a wrong device in the vicinity when using CC2540 USB dongle with BTool.

    Note: Please go through the documentation on BLE functionality available in www.ti.com/.../ble-stack first. It shopuld give you a basic understanding of different modes of operation.

    Regards,
    Arun
  • This is what I am doing.

    Step 1: Programmed the CC2541 with "Host Test Release. Turn the power OFF and then Back ON.

    Step2: Run BTool on PC with USB bluetooth dongle plugged into the computer

    Step3: Scan and then established the link. 

    CC2541 is not connected to any external microcontroller yet. I thought that the Host Test Release is a stand alone application.   What are the right steps to follow? You see TI does not mention any steps that I need in the documents. It seems like these  documents were written by a Robot. or you know by some kind of lawyer. 

    Look the documentation you are referring again and again are not user friendly unless you have a PhD in bluetooth. There are commands in the documents but if I want to implement them in microcontroller than I do not know what equivalent hex numbers of those commands do I need to send to CC2451 chip.

    For example what numbers do I have to send to the CC2541 to advertise,  is not given in those doucments that you are referring to again and again. 

    dave

  • Hi Dave,

    I can understand that, using BLE is not easy unless you get a grasp of the basic concepts used in it. That is why we are asking you to go through the software developer's guide first to get an understanding of different concepts, procedures, configurations etc before proceeding further. The examples there give you a good understanding of the procedures used by peripheral devices to start advertising, connection/disconnection procedures and data read/write request handling. Once you understand these examples, you will come to know of the various commands and their parameter values to use from your external MCU connected to CC2541.

    Anyway we will try to enhance our documentation and examples to develop app notes to explain concepts & examples which would help customers in faster development.

    Regards,
    Arun
  • You are right. I am using CC2540USB dongle to connect to PC(which runs Btool)? and then trying to connect to CC2541 over BLE connection. The documentation never said that I can not do this. Why is it not possible?

    The documentation does not suggest how to connect the CC2541 to PC over UART with what software either. If documents were written properly for all kind of audiences then TI might not have to build the support forum at all.

    I have not found a single block diagram about what am I trying to do in the documentation.

    Best,
    dave
  • The HostTestRelease application uses Network processor configuration(dual chip scenario) and hence requires a host MCU to control it. You can run a simpleBLEperipheral example on CC2541 which uses single chip peripheral role to accomplish what you are trying to to do with Btool connected to CC2540USB dongle.

    The interface for connection CC2541 to PC serial port varies from which reference design you are using(sensor Tag, keyfob, EM, other third party modules) etc. You need to connect the UART TX and RX pins to an RS232 cable and open a COM port on PC to start communication with it. Please refer to the board schematics to find out on which pins are the UART Rx, Tx and Gnd pins are coming.

    Regards,
    Arun
  • Hi,

    I tried the "SimpleBLEPeripheral" example too and I got the following results . The thing is that I was unable to find the any "UART" configuration with the project. It comes with following configuration options . Best Dave

    1. cc2541
    2. cc2541DK-MINI KEYFOB
    3. cc2541-OAD-imgA
    4. cc2541-OAD-ImgB
    5. cc2541-OAD-Encrypted-ImgA
    6. cc2541-OAD-Encrypted-ImgB

    [1] : <Tx> - 01:35:56.199
    -Type : 0x01 (Command)
    -Opcode : 0xFE09 (GAP_EstablishLinkRequest)
    -Data Length : 0x09 (9) byte(s)
    HighDutyCycle : 0x00 (Disable)
    WhiteList : 0x00 (Disable)
    AddrTypePeer : 0x00 (Public)
    PeerAddr : B8:9A:14:BB:D6:98
    Dump(Tx):
    01 09 FE 09 00 00 00 B8 9A 14 BB D6 98
    ------------------------------------------------------------------------------------------------------------------------
    [2] : <Rx> - 01:35:56.221
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x067F (GAP_HCI_ExtentionCommandStatus)
    Status : 0x00 (Success)
    OpCode : 0xFE09 (GAP_EstablishLinkRequest)
    DataLength : 0x00 (0)
    Dump(Rx):
    04 FF 06 7F 06 00 09 FE 00
    ------------------------------------------------------------------------------------------------------------------------
    [3] : <Info> - 01:35:57.935
    Device Connected
    Handle = 0x0000
    Addr Type = 0x00 (Public)
    BDAddr = 98:D6:BB:14:9A:B8
    ------------------------------------------------------------------------------------------------------------------------
    [4] : <Rx> - 01:35:57.921
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x13 (19) bytes(s)
    Event : 0x0605 (GAP_EstablishLink)
    Status : 0x00 (Success)
    DevAddrType : 0x00 (Public)
    DevAddr : 98:D6:BB:14:9A:B8
    ConnHandle : 0x0000 (0)
    ConnInterval : 0x0050 (80)
    ConnLatency : 0x0000 (0)
    ConnTimeout : 0x07D0 (2000)
    ClockAccuracy : 0x00 (0)
    Dump(Rx):
    04 FF 13 05 06 00 00 B8 9A 14 BB D6 98 00 00 50
    00 00 00 D0 07 00
    ------------------------------------------------------------------------------------------------------------------------
    [5] : <Info> - 01:35:58.435
    Device Disconnected
    Handle = 0x0000
    Addr Type = 0x00 (Public)
    BDAddr = 98:D6:BB:14:9A:B8
    ------------------------------------------------------------------------------------------------------------------------
    [6] : <Rx> - 01:35:58.432
    -Type : 0x04 (Event)
    -EventCode : 0xFF (HCI_LE_ExtEvent)
    -Data Length : 0x06 (6) bytes(s)
    Event : 0x0606 (GAP_TerminateLink)
    Status : 0x00 (Success)
    ConnHandle : 0x0000 (0)
    Reason : 0x3E (Failed To Establish)
    Dump(Rx):
    04 FF 06 06 06 00 00 00 3E
    ------------------------------------------------------------------------------------------------------------------------
  • Hey,

     I am trying something similar as yours, with cc2541 Evaluation modules. I have loaded Host Test App - cc2541EM configuration. But, I am not able to do UART communication with it. But, I was able to do the same with cc2540 keyfob. It is responding to all HCI commands. cc2541 EM not is not responding to any. Please help me with this. Thanks in advance.