Introduction: Bluetooth Low Energy Bare Metal
I wanted to do some IoT projects and needed a Bluetooth Low Energy solution. I bought a TI sensorTag and really liked it. They had a ton of sensors on it and the new TI CC2650 chip was cool. But, they didn't really support free software tools. The clincher was their antenna design comes off the chip perpendicular to the edge of the chip, and then the antenna extends beyond that. This would make the PCB for my design too long. I then looked at Nordic Semiconductor. There antenna design runs parallel to the chip edge so it would fit.
So, here is my getting up to speed instructable.
To start, I ordered these bare metal designs from Seeedstudio. They are only $6.68 each. Almost all other designs are closed firmware, where you communicate through a UART. I needed more power than that. Scroll down and download the datasheet for the pinouts.
I also needed a JTAG to program them, so I got the Segger J-link EDU (education) for $63 from Digikey.
I also needed an ARM GNU compiler and tools:
I had trouble with the Yagarto toolchain with this chip.
Also, since the chip on the seeedstudio boards is the Nordic semiconductor N51422-QFAA, I went to their site and downloaded the nRF51 SDK v9.0. They have since gone to v10. I haven't tried it yet.
Download Segger embedded studio software for your J-link EDU debugger.
To test the final programmed board working, you need a way to connect and see the Bluetooth Services and characteristics. I had a BlueGiga BLED112 and downloaded their BlueGUI.
Scroll down for the software for the BlueGiga.
Step 1: Hooking Everything Up
I soldered some .05" headers to the Vcc,GND, swdio and swdclk pins on the board. See the photo. I used some .05" to .1" boards I had, you will have to solder on wires with .1" pins to push into the cable. I then used a old Sparkfun Pro Mini I had lying around as a 3.3V source. A power supply would be the correct thing. Hooking up the J-link is tricky. If you go online, even to Seggers site, it will be confusing. I used the blue line on the J-link flat cable as the pin 1 indicator. Just follow my photo. The yellow wire is swdclk. Also, the orange wire goes in pin 1 of the j-link cable and is 3.3V, same as Vcc. This sets the levels on swdio and swdclk coming from the J-link, so it doesn't fry your chip.
To setup the J-link, launch J-link commander and update the firmware. The with everything hooked up, launch J-link flash. Choose the project file "nRF51422_xxAA.jflash" in "C:\Program Files (x86)\SEGGER\JLink_V502\Samples\JFlash\ProjectFiles\NordicSemi". If everything is hooked up right then choose connect to target. If successful, you should see like the photo where it ways connected. If it says 0V, the 3.3V is not in pin1 (Vref) like the orange wire in my setup.
Now we can move on to the actual firmware.
Step 2: Fix Software and Compile
Open a command window, start a file window and start your editor.
In the command Window, go to this path inside where you unzipped the SDK:
Go to the same directory in you editor and open:
"ble_app_hrs_gcc_nrf51.ld" and change this line like this:
RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000
This sets your RAM to 8k instead of 16k.
Then open "Makefile":
1. Put this near the top
GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Tools ARM Embedded/4.9 2015q3
2. Go down to where the line starts with "flash:" and make it literal, like this:
@echo Flashing: $(OUTPUT_BINARY_DIRECTORY)/nrf51422_xxac_s110.hex nrfjprog --reset --program $(OUTPUT_BINARY_DIRECTORY)/nrf51422_xxac_s110.hex
Now type "make" in the command window. It should work.
Step 3: Program Stack and App
This should work if your setup is okay. At the command prompt, type:
This puts the Bluetooth stack on your board. Then:
This should put the heart rate example on you board.
Step 4: See If It Worked.
The photo shows what you should see in BLEGUI. You have succeeded! Yay!
I understand this instructable might seem confusing, because there was a lot going on. Shoot me a comment and I will fill in with text and photos (whatever clears things up).