Some experience records of BLE-CC2541 project
[Copy link]
BLE CC2541 as low-power smart hardware
Introduction
: Recently, due to project needs, CC2541 is used to make a smart hardware similar to a Bluetooth bracelet, which can collect human body temperature, device power, Bluetooth signal strength (anti-lost device), and other simple functions. Although it is not very difficult to develop based on the SDK provided by TI, some more daunting problems were still encountered in the process. I recorded them for future reference and also as a tip for future novices.
Development Environment
(1) The
entire software development is based on the BLE-CC254x-1.3.2 protocol stack provided by TI. To run this protocol stack and the routines provided in it, you must use the development environment of IAR Assembler for 8051 9.30.1.3056 (9.30.1.3056) or above. There is a harmonious version of this now, which needs to be installed and cracked by yourself. There will be no big problem if you follow the tutorial step by step.
In addition, you need to install several BLE development and debugging software provided by TI: BLE Device Monitor, BTool, SmartRF Flash Programmer, SmartRF Packet Sniffer, SmartRF Studio 7. I have packaged and organized these software.
(2) The CC2541 development board
does not have a debug interface, which is the most annoying thing, and it makes the development efficiency very low. When developing devices in the future, you must leave a debug interface on the device. After the product iteration is stable, remove the debug interface. All my early development was done on the development board.
(3) CC Debugger
(4)USB Dongle
(5) The BLE sensor tag on the iOS side and the device monitor on the Android side are also good debugging assistants. After
installing the above software, you can open a simple example provided by TI, compile and burn it into the board, then open the BTOOL software, use the USB Dongle to scan -> load seeting -> establish, and then you can capture the data packets sent by the Bluetooth device.
If you have completed the above steps, then congratulations, you have entered the BLE development.
Understanding the Bluetooth protocol stack
(1) OSAL
To understand TI's Bluetooth protocol stack, OSAL is indispensable. If you are familiar with embedded operating systems or Linux, you should be able to understand it very quickly.
(2) Profile
The specific
development work was carried out on the basis of the routine KeyFob Demo provided by TI. The basic services provided therein, Generic Access Service, Generic Attributes Service, Device information Service, Simple Profile Service, were utilized, and two services were added according to needs: Simple Key Service, OAD service. It is actually very simple to develop the application layer based on the routines provided by TI. The main thing is to understand the following concepts.
(1) Task
(2) Event
(3) Message mechanism
(4) Callback function
(5) HAL
hal is a hardware driver provided by TI, which contains the drivers of all CC2541 internal modules. Generally speaking, we do not need to directly operate on this hardware abstraction layer. We only need to build on the framework
Power Saving Mechanism
Speaking of low power consumption, this is a trend in smart hardware nowadays. In order to improve the user experience, TI officially claims that CC2541 can achieve a year of standby time when powered by a button battery. That is achieved when the device enters the ultra-low power consumption PM3. Under normal circumstances, our devices need to wake up frequently. When it comes to low power consumption, we need to study how the device is dormant and woke up in the protocol stack?
In the actual development process, the amount of power consumption is linked to the specific tasks performed by the device. When OSAL detects that there is no scheduled task in progress, the system will enter PM2 mode from active mode. In this mode, the system's sleep timer is counting, and when it times out, the system will automatically wake up. If the program has no scheduled tasks to execute, the system will enter the lowest power consumption PM3 mode. At this time, only a reset operation or an external interrupt can wake up the system.
OAD (Over-the-Air Update)
is a very useful feature, especially in the current situation where smart hardware needs to be continuously updated. The firmware can be upgraded wirelessly directly through our software package or a dedicated APP, eliminating the need for a download interface and greatly reducing the size of the product.
I originally wanted to give a brief summary, but found that many things could not be explained in too much detail, so I decided to read it again and explain some of the substantive details.
|