I am having trouble doing what I think *should* work, using my Bluetooth LE mini-dev kit. I have the USB dongle attached to the computer, running BTool on my PC. I flashed the keyfob device with the SimpleUSBPeripheral, and confirmed that a "Scan" using BTool revealed the keyfob address when I push the keyfob button to make the keyfob discoverable.
What I am now trying to do is use the UART from my PIC24F microcontroller to enable discoverable mode using HCI commands. I have opened the HostTestApp CC2540 *.eww workspace file in IAR Workbench, and associated CC2540EB with the project, instead of CC2540USB--I am assuming that this opens up my device to be controlled via the 4 UART ports using HCI commands. I reflashed the CC2540 with this HostTestApp CC2540EB *.hex file. I have made the following connections between my PIC and the CC2540:
UART TX: P0.2
UART RX: P0.3
UART CTS: P0.5
UART RTS: P0.4
I am now simply using the following code to implement the Make Discoverable command over HCI:
U2TXREG = 0x01;U2TXREG = 0x06;U2TXREG = 0xFE;U2TXREG = 0x00; if (U2BRG==0xFF) U2BRG=0x00; U2BRG++;
The last three lines of code are just to iterate through Baud Rate settings to rule out the Baud Rate as the issue. This code is executing in a loop, so it's rapid, but earlier I was toggling each iteration of this block of code with a pushbutton. I am testing success or failure by running "Scan" on BTool, with the USB dongle still connected, and everything to do with the PC in the same configuration as when I tested the "discoverability" behavior of the keyfob device with the SimpleBLEPeripheral application flashed. If I execute this code on my PIC using the UART, and I am in "Scan" mode using BTool....then I should see the keyfob device address show up. No luck so far.
I am thinking that I need to change the order of my UART code, or am I missing something to do with the bigger picture? Any help is really appreciated!
Hello Miles Guidon,
Have you successfully running your application now?
I am trying the case like you right now.
So I advise that you must change the configuration of "hal_board_cfg.h" to enable the UART HCI processore,
you must make sure you have defined below:
#define HAL_UART TRUE
#define HAL_UART_ISR 1
If you already successfully fixed it, pls. make me know, I also need your help.
hi miles,
i am also struggling with the same problem...did you find the solution.. the same configuration but no response in the btool...
I did find the solution. The two things you need to make sure of are that you have defined GATT_DB_OFF_CHIP in your preprocessor definitions (IAR Workbench -> Options -> Compiler), and also that you are using the correct Baud rate. I thought I had the correct Baud rate, but I really didn't.
I have a logic analyzer that can decode UART transmissions if you tell it what Baud rate you are using--this is a useful tool if you want to make sure you are achieving the Baud rate that you think you are.