Last time we have made a good starting point with setting up a project template for the 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 a button library. This is a modest implementation that initializes port pins and then reads their status. The Development board is equipped with four user-programmable buttons named WAKEUP, TAMPER, USER1, and USER2. We will not care about the meaning of names; use them as general-purpose buttons for now.
The LPC2148 development board is a mighty board with an ATM7TDMI series microcontroller considered an old guy compared to Cortex ones. But still, these are widely used and are powerful. The Development board has some handy features installed. 12MHz crustal allowing to run the 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 a serial-in parallel-out shift register, 2×16 LCD, buzzer, audio jack with an amplifier, two programmable buttons, and 256Kb of I2C interfaced EEPROM. The 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 a great board for prototyping and end application.
I found some time to play with the STM32F103ZET6 development board and decided to set up a simple project for it. The trickiest part of this is to set up a project environment that would serve as a template for the following developments. Many ARM developers chose the 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, the code will work on both. Let’s stick to CodeSourcery. Just download it and install it on 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.
The latest development board has just arrived. I thought it would be nice to push things more towards the ARM cortex-M3 playground. This an STMicroelectronics STM32F103ZET6 ARM Cortex – M3 MCU based development board with a 3.2” Touch LCD screen. This is a high – density performance line 32 -bit MCU featuring internal 512K of FLASH memory, 64K of RAM. It is rich in peripherals like USB, CAB, 11 timers, 3ADC, and many communication interfaces. The microcontroller seems to be powerful enough to run quite intensive tasks, but more memory is populated on board. Additionally, there are:
The float numbers are not recommended to use with smaller 8-bit AVR microcontrollers. The main reason is that the AVR core does not have a floating-point arithmetic unit built-in. The software library emulates the floating-point arithmetic operations. The software library simulates Floating-point arithmetic operations. However, in real-world applications, you may need to use numbers with floating-point. In some particular cases, you can get away without you declaring variables as float type. If operations are simple like division or multiplying by 2, 4, 8, they can be replaced by the byte shift operation (byte<<1)=byte*2 Of course, it depends on the different situations and data you are manipulating – sometimes using floats is inevitable. If your code fits into Program memory and execution speed is not critical, use floats or double number formats, as you like.
The Olimex ARM JTAG clone is well known as there are many schematics on the internet available. Circuits are straightforward and seem to be reliable. This adapter can also be set up to work with WinARM tools: obdremote and gdb/Insight-gdb. In the circuit, there is a critical part that needs to be considered – 74HC244 buffer IC. Family of HC support less than 4.8V if powered with 3.3V. But reality shows that Parallel port voltage usually is lower than 5V so that HC will fit. But of course, it is better to measure the HIGH state of parallel port pins. To be more sure, HC should be replaced by 74LVP244 or 74LPT244. These chips support 5.5V in entry with a 3.3V supply, but sometimes they are hard to find in the market.
LPC2000 series of microcontrollers have a built-in Real Time Clock (RTC) unit, which may be used for counting time to maintain a calendar and clock. RTC is designed for low power designs that enable use in battery-powered designs. The real-time clock can count time in Seconds, Minutes, Hours, Days of Month, Months, Years, Days of the week, and Days of Year. The real-time module can be clocked using a distinct 32kHz clock oscillator or internal prescaller from the VPB clock. The real-time clock unit has additional power supply pins (3.3V) that allow the RTC clock to work when the system is off – actually power-down mode operated from the clock battery. As there are many functions in clocks like time units(seconds, minutes, etc.) and alarms, there are quite some registers to cover clock functionality. There are several groups of registers:
In ARM7 microcontrollers, PWM is designed as a separate module, but it has all features as general-purpose timers have; just limited pins are associated. PWM module has improved match module, allowing six single edges controlled PWM or three double-edge controlled PWM. There are seven match registers used with improved update logic. PWM modulator has additional shadow match registers that perform the latching effect. This means that you can instantly update match registers, but new values are taking effect only at the beginning of the new cycle. This mechanism ensures that all updates are performed at the beginning of a new cycle through the latch enable register(LER). In general-purpose timers, match registers take effect immediately after they are updated.
LPC2000 microcontrollers have at least two 32 bit timer counters. Let’s take the LPC2148 microcontroller, two general-purpose 32-bit timers that are identical except the peripheral base address. These timers are for general purposes that can perform timer and counter operations. Timers have many features: Programmable 32 bit pre-scaler; Up to four 32 bit capture channels that can take snapshots with interrupt generation ability; Four 32 bit match registers that allow generating interrupt on the match, generate interrupt and stop the timer, generate interrupt and reset the timer; Up to four output pins that can be set LOW/HIGH/TOGGLE on compare match;
Microcontrollers aren’t imaginable without interacting with other devices like indicators, input devices, or other off-chip devices. For this, every MCU has I/O pins that are used to interact with the external world. General-purpose I/O ports can be accessed via registers that provide enhanced features or simply via port registers. Port registers are allocated to the ARM bus so that fast possible timing can be achieved. Control of individual bits is possible using a single instruction. All port registers are byte and half-word addressable. After MCU reset, all I/O ports are set to input. Let’s take the LPC2000 series ARM microcontroller LPC2148. It has two 32 bit general purpose I/O ports PORT0 and PORT1. PORT0 has 30 pins for input/output operations, where one is only for output. PORT1 has 16 available pins for GPIO.