Home » PCB/Hardware hacking
I wanted to experiment with Bluetooth Low Energy:
- Can you hack together in your garage an antenna and RF section that will work at 2.4GHz?
- If it works, who good/bad will it be?
- What is hand soldering QFN packages like? Many BLE devices are only available in CSP or QFN48.
If you want to make IoT and Wearable devices that can be controlled from your phone/tablet/whatever, ZigBee is a neat mesh networking technology; but it’s not in any phones. Bluetooth (and more recently) Bluetooth Low Energy is in all of them. It’s easy to write a BLE control app write yourself using the Cocoa frameworks or download one like the excellent LightBlue for iPhone:
Though many eval boards come with an embedded JTAG-USB interface, I still like to use a separate purpose-built JTAG debug box.
If you pick the right one:
- It can be used with many boards and SoCs. Once set up, one debug toolchain works for many projects.
- You can use it to debug MCUs on bread-boarded projects. You will need to make a hacked SWD cable like the one I show in this post.
- Not that expensive. I picked up a Segger JTAG EDU on a home-use deal for $60. I remember the early days at ARM when we first launched our “EmbeddedICE” box; the price then was over $1K….Today you can get some very cheap $20 knock offs from China on EBay and AliExpress. These may or may not work, but I believe it not worth my time to rely on dodgy tools with questionable software.
- It works natively with Mac OSX. At least the Segger version does. I don’t need to run Fusion, Parallels or Virtual Box.
- Does not require special USB drivers etc. The Mac version works by looking like a TCP device and speaking IP.
- Supported directly under Eclipse. Again no special driver required
- Supports SWD or full JTAG
(1) Connection to the target
The first thing you will need is a SWD cable. I made one out of some 20 core ribbon cable and a 20 pin IDC box connector. The ARM documentation on SWD pinouts is highly ambiguous since they talk about the pins to a “connector”. What’s a connector? Do they mean the plug (male) or socket (female)? I figured out the Segger pin out by using a Salaea Logic Analyzer:
(2) Get the Segger software tools working
On a Mac, this is as simple as starting the JLinkExe terminal application in the Segger Application folder. Don’t try and use the JLinkGDBServer app from terminal.
If all is well, JLinkExe reports something like this:
Note how JLinkExe switched automatically to SWD. This works most of the time, but not always. It depends on whether your target device is “known” to the box or not. If it is not known, you can fix this by read more
I used a header board for an STM MEMS evaluation kit in order to take a look at some common MEMS sensors:
- LPS301: Pressure and temperature sensor
- LG3D20: Gyroscope
- LSM303DLHC: Accelerometer and magnetometer
The header was an STEVAL-MKI124V1 which is designed to work with an STM motherboard evaluation system. I took a shortcut and used it with an ARM MBED board featuring an NXP LPC1768 MBED.
Hook-up using I2C was trivial:
The schematic for the evaluation board is here:
The orientation of the sensors on the board is like this:
MBED-based code I write to drive the I2C is on the MBED website here
The code sets up each of the sensors and then provides a continuous output of temperature, pressure and orientation. Rather than optimize for performance or efficiency, the code here is intended to show clearly how to access the sensors.
An interesting twist was to use the linear accelerometer to find the vector of the earth’s gravitational field (i.e. down) and to use that to make a tilt-adjusted compass. Algorithm read more
Quick and simple project to make an adapter PCB to use a QFP packaged MCU on a traditional through-hole breadboard.
I ended up making a double-sided PCB to support 2 different QFP sizes. One side set up for 48 pins, the other for 32pins. Usage is to populate one side or the other, not both….
Simple pin-out to two standard 24-pin headers. No on board components such as decoupling capacitors.
Here is the board in action on a breadboard and loaded up with a 48-pin STM32F100C8:
Eagle files for the board are on GitHub here.
Powering up a new board design or even skiing off-piste with an eval board without vendor-suppled code? This post shows a way to look for first signs of life without depending on working debug toolchain or working target software.
I use a Segger JTAG probe that I covered in a previous post.
Some recent eval boards like the one for Nordic Micro’s nRF51822 ship with an on-board USB debug connection that has a USB-JTAG decoder chip on board. This board uses the same Segger driver as their JTAG box embedded in the decoder, so the below approach should also work.
Segger JLINK application driver has a series of useful commands for examining directly addresses in memory:
- mem Read memory. Syntax: mem , (hex)
- mem8 Read 8-bit items. Syntax: mem8 , (hex)
- mem16 Read 16-bit items. Syntax: mem16 , (hex)
- mem32 Read 32-bit items. Syntax: mem32 , (hex)
Since many MCUs have a factory-programmed ID register, you can use JTAG to read this value and check for signs of life.
To start with, I target a STM32F100C8. This MCU has a register at 1FFFF7E0 hex containing a 16-bit value with the flash size of the MCU. This is covered in the STM32F100 programming manual on read more
I was looking for a way to test the frequency response of a new oscilloscope.
Analog Devices has a nice IC that can produce a digitally synthesized sine wave of frequency between 0 and about 70 MHz. AD9850 link is here.
The quickest way to throw together a prototype was using an MBED platform. My code is here
What made things even easier was the availability of ready-to-go evaluation boards from China on Ebay for less than $5. This is the one I used.
This design is limited to about 40MHz if you want a clean signal without aliasing.
Frequency and phase are set by a 40-bit command that has:
- 32-bit frequency setting
- 5-bit phase setting
- 1-bit power up/down
- 2-bits factory debug access
Output frequency is given by: fOUT = (frq × CLKIN)/(2^32)
where frq is the 32-bit frequency and CLKIN is the frequency of the on-board crystal (125MHz in this case) So, for example 0x147AE148 is 10MHz.
Frequency resolution has a step size of 29KHz with the 125MHz clock.
You can also change phase in increments of 180°, 90°, 45°, 22.5°, 11.25° or any combination thereof using read more