So far we’ve been using an old template with CMSIS version 1.30. Since then it was updated several times by adding support of new Cortex processor families, fixing several bugs and adding new features. They also changed the folder structure of CMSIS to be more generic. And there is a CMSIS DSP library integrated. With it, you can do complex math tasks using only a few lines of code. So why not upgrading our software template for Sourcery Codebench G++ toolchain with new CMSIS. Also, we are going to get rid of external makefile with ARM GCC Eclipse plug-in. How to install and use this plugin we discussed in previous posts (part1 and part2). First of all download the latest CMSIS package from arm.com/cmsis. You will have to register to access download files. Package with CMSIS, DSP library and documentation weights about 45MB. Since we are working with ST32 microcontrollers, you also need to download STM32F10x Standard Peripheral Library from STMicroelectronics.
Continue of part 1. First of all, let us select the proper processor type. As we are using Cortex-M3 processor, then we go to Project->Properties menu (or right click on project name in the project explorer and select Properties). First, in Tool Settings list is Target Processor. So we select processor cortex-m3: Be sure to choose settings for all configurations, so you don’t have to do this twice when selecting Debug or Release.
Eclipse is an excellent multiplatform graphical interface practically for any language. If you choose to use it – you won’t loose. We’ve been using it when writing software for ARM microcontrollers. As compiler Mentor Graphics Sourcery Codebench Lite works just fine. If you have both – Eclipse and Sourcery tools installed we can move on. So far in our earlier project we’ve been using an external makefile project setup. This means that we had to write/edit makefile in order to compile and link project files. This is hand job and requires some knowledge and time. You cannot run away from them if you are using free tools, but there should be some way out and automate at least some parts of this work. Eclipse Indigo comes with CDT C/C++ development tools. It works excellent with general C/C+ projects and we’ve been using it without problem along with external makefile and project settings. But there is a better way of developing project for ARM platforms. It’s GNU ARM Eclipse Plug-in. It supports most of GNU toolchains including Sourcery Codebench Lite, Yagarto, GNUARM, WinARM and other. So lets set up Eclipse to use this plugin and see how it works.
As you may know, ST also produces his own debugger/programmer called ST-Link. It supports JTAG and SWD interfaces. You can purchase an ST-Link USB adapter, but there is a better option if you are into STM32 microcontrollers, and probably own one of ST32 Discovery boards. Since I have STM32VLDiscovery nearby, this is how to program another STM32F103RBT6 board using only four wires. On discovery board, locate CN3 jumpers and disconnect them as they connect discovery board to a debugger.
Last time we have covered the topic about flashing STM32 microcontrollers using the bootloader, which is the most comfortable and cheapest way of loading programs into MCU memory. But this isn’t the only way of doing this. The firmware can also be downloaded using the JTAG adapter, which is also used for debugging. This time we are not digging into debugging but staying only with programming. J-Link software You can download latest J-Link software from Segger Download page.
STM32F103R board is a simple and easy development board to learn STM32 microcontroller programming. Its heart is STM32F103RBT6 ARM Cortex-M3 microcontroller with 128K of Flash and 20K of SRAM memory. It can be clocked at the maximum 72MHz frequency and is considered to be a medium-density performance line microcontroller. Other features include USB, CAN, seven timers, 2ADCs, and nine communication interfaces. Development board has several nice features to get started. First of all, it has an RS232 interface for communicating and accessing bootloader. There also is a USB 2.0 full speed interface connector that also can work as the power supply. Next is a JTAG connector to program microcontroller using tools like J-Link adapter. Two push buttons and two programmable LEDs are hardwired to MCU pins alongside all I/Os connectors.
STM32F103ZET6 board comes with 3.2 inches graphical LCD which features an ILI9320 controller. Equipped LCD is capable of displaying 252144 colors when driven in 18-bit mode. We are going to run it in 16-bit mode, so we are limiting it to 65K colors. LCD driver is based on existing code found on the internet which was originally developed for STM3210E board. Only minor modifications were needed like assigning right control pins.