Project demo on STM32F103RBT6 using GCC

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.

Continue reading

Driving Graphical LCD with STM32F103ZET6

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.

Continue reading

Connecting STM32 USART to standard I/O streams in GCC

In many situations when working with STM32 microcontrollers, you will want to output text strings. There is no need to write specialized functions that output specially formatted strings as it is hard to keep up with various cases. It is convenient to use standard I/O streams and its library functions that allows sending formatted data streams. Arm GCC toolchain comes with newlib C library from Redhat, and so it isn’t specially designed for embedded toolchain. To use stdio functions we have to take care of several syscals so-called “stub functions.” These functions usually are provided by operating systems like you would write C programs in Windows or Linux. In our case, we aren’t using any OS, os to avoid error messages while compiling we have to provide these function declarations where most of them are dummy implementations. It’s not something new pick one that you find on the internet. I noticed that it was written for STM32 Discovery.

Continue reading

Interrupt based button read on STM32F103ZET6 board

In the previous example, we implemented a simple demo program that reads buttons by continually checking their status in the main program loop. This isn’t an efficient and convenient way to do that. Imagine your application has to do lots of tasks, and in between, you also need to check button status – mission becomes impossible unless you use interrupts. In this part, we briefly introduce to STM32F10x interrupt system and write example code where LEDs and buttons are serviced within interrupts. ARM Cortex-M3 microcontrollers have advanced interrupt system that is pretty easily manageable. All interrupts are controlled inside Nested Vectored Interrupt Controller (NVIC) which is close to the Cortex core to ensure low latency and robust performance. Main features of NVIC include:

Continue reading

Implementing buttons on STM32F103ZET6

Last time we have made a good starting point with setting up a project template for STM32F103ZET6 development board using GNU tools. Using the same project template, we can move forward and start programming other elements. This time a quick note about adding button library. This is a modest implementation which initializes port pins and then reads their status. Development board is equipped with four user programmable buttons named WAKEUP, TAMPER, USER1, and USER2. We are not going to care about the meaning of names use them as general purpose buttons for now.

Continue reading

Driving LEDs with LPC2148 microcontroller

Couple years ago I have purchased LPC2148 development board called BlueBoard form ngxtexhnologes. It is quite powerful board with ATM7TDMI series microcontroller which is considered an old guy comparing to Cortex ones. But still these are widely used and are powerful. Development board has some handy features installed. 12MHz crustal allowing to run processor at full 60Mhz speed. Couple RS232 ports, VGA connector, PS/2 connector for keyboard or mouse, 20-pin JTAG, SD/MMC slot, USB B-type, 8 LEDs driven with serial-in parallel-out shift register, 2×16 LCD, buzzer, audio jack with amplifier, two programmable buttons and 256Kb of I2C interfaced EEPROM. Microcontroller itself has 512KB of internal flash and 32+8KB of RAM. All ports are accessible and any external hardware can be disconnected with jumpers. This is great board for prototyping and end application.

Continue reading

LED blinky demo on STM32F103ZET6 development board

I found some time to play with the STM32F103ZET6 development board and decided to set up a simple project for it. Probably the trickiest part of this is to set up a project environment that would serve as a template for following developments. Many ARM developers chose CodeSourcery Lite edition toolchain. It has full command line functionality – this is what we usually need. If you want some alternative – you can select gnu yagarto ARM toolchain which is also great and free. No matter which tool you select code will work on both. Let’s stick to CodeSourcery. Just download it and install to your PC. As we said Lite version supports only command line tools – we need an interface for it. Eclipse IDE is one of the favorite choices so that we will grab this one too. Yagarto website has an excellent tutorial on how to set up the Eclipse IDE in a step-by-step manner. We won’t go into details with this.

Continue reading