Implementing buttons on STM32F103ZET6

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.

Continue reading

Driving LEDs with LPC2148 microcontroller

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.

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. 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.

Continue reading

New STM32F103ZET6 development board with 3.2″ TFT Touch LCD

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:

Continue reading

How to sprintf float numbers with AVR GCC

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.

Continue reading

AVR analog comparator and avr-gcc example

An Analog comparator is a pretty simple peripheral, but it can give big benefits. Comparator module is included in all Mega series of AVR microcontrollers. Simply speaking, Comparator allows comparing voltage values applied to two pins of microcontrollers. The comparison results are a logical level, which can be read by the program(ACO- Analog Comparator Output bit). There is also the ability to generate an interrupt, which depends on the comparator resulting level. And more- timer T1 can capture this level what allows measuring the signal length of analog signals. To use pins as comparator inputs, they must be prepared and configured as input(DDRx=0), and pull-up resistors must be disconnected (PORTx=0). In some models like Atmega48x/88x/168x, Atmega165x, Atmega325x,3250x,645x/6450x, and Atmega640x/128x/1281x/2560x/2561x, there is the ability to disconnect digital buffers of AIN0 and AIN1 pins that allows the use of these pins only for analog signal input – this minimizes overall power consumption.

Continue reading

JTAG wiggler clone for ARM microcontrollers

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.

Continue reading

Real time clock of LPC2148

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:

Continue reading

Pulse Width Modulator in LPC2000 ARM7 MCU

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.

Continue reading

Timer Counters in LPC2000 microcontrollers

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;

Continue reading