Introduction to CC2541

Exploring the versatile AVR microcontrollers or the powerful STM32 counterparts were amazing experiences which resulted in interesting projects, many of them presented on this blog. For a hardware designer, the multitude of options can be overwhelming and this is a good thing. In regards to BLE (Bluetooth Low Energy) applications, TI’s CC254X solutions are appealing to say the least. “The CC2541 is a power-optimized true system-on-chip (SoC) solution for both Bluetooth low energy and proprietary 2.4-GHz applications … The CC2541 combines the excellent performance of a leading RF transceiver with an industry-standard enhanced 8051 MCU, in-system programmable flash memory, 8-KB RAM, and many other powerful supporting features and peripherals. The CC2541 is highly suited for systems where ultralow power consumption is required.”

CC2540 vs CC2541

There are several BLE Modules based on CC2540 and CC2541 available for a low cost.
ble_cc2540_cc2541_modules
These chips have the same pinout and can be substituted if taking into account the two big differences between the CC2540 and the CC2541. First the CC2540 comes with higher transmit power (4dBm vs 0dBm) at the cost of higher consumption (27mA for transmitting @4dBm vs 18.2mA of the CC2541 for the 0dBm). The second thing is that the CC2541 removes the support for USB available in the CC2540 and instead, it introduces hardware I2C on the same pins. If you are using I2C, this could be one good reason to use the CC2541, while software I2C is also possible.

The first application

The reason why I approached the CC2541 was for designing an air pollution system to be used primarily by bicyclists and joggers to map pollution in cities.
uradmonitor_air_sketch_s
This device is envisioned as a low weight, low power wearable, sensing pollution via the excellent BME680 sensor from Bosch. A BLE link to a smartphone is all that it takes to visualise the data, but also send it in the background to the uRADMonitor servers. A CC2541 will handle the BLE natively and thanks to the 8051 core will do the additional computation to read the BME680 via I2C and send the data to a smartphone. All components fit the low energy requirement while delivering precious air quality measurements: temperature, pressure, humidity and volatile organic compounds (VOC).

The toolchain

Before jumping to TI’s BLE stack, we’ll need to prepare the toolchain. This includes two steps: first I’ll need a programmer and its software, and then a compiler for the 8051 core. Getting this far will allow compiling the BLE Stack to have a working bluetooth device based on the CC2541. Next, I’ll only need to include I2C functionality to link to the BME680 and a minimalistic protocol to export the data via the wireless link. Ideally, all the software components should run on MacOS.

The programmer
I went for the CC-Debugger that can be used to program and debug the multiple 8051-based system-on-chips from Texas Instruments: CC1110, CC1111, CC2430, CC2431, CC2510, CC2511, CC2530, CC2531, CC2533, CC2540, CC2541, CC2543, CC2544, CC2545.
cc_debugger_cc2541
To use this programmer on MacOS, I compiled the excellent cctool available for Linux OS on Sourceforge. If anyone needs the MacOS binary, it is available cc-tool. The connections are the following:
hm-10_cc_debugger_connections_cc2541_ble
Here’s an example:

The compiler
Two options here, the IAR workbench and the SDCC plugin for Eclipse. Needless to say that the latter is my favourite.

Hello World

For a first test I downloaded the TI BLE stack to try to recompile it and upload the code to one of the CC2541 based BLE modules (HM-10). Unfortunately this download is an .exe and will need a Windows machine to run. Once we get past this embarrassing step, we are able to use the extracted files on any machine.
The SDK comes with many examples that are a good starting point for other applications. The SensorTag and Keyfob are very similar to the first application I envisioned for the CC2541. More news soon.

This article has 3 Comments

  1. Hobbies and DIY are the engine behind everything, as without passion nothing moves 🙂

Leave a Reply