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 same project template we can move forward and start programing other elements. This time a quick note about adding button library. This is really modest implementation which simply 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 meaning of names just 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

Found some time to play with 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 template for following developments. Obviously we choose GCC development tools. 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 choose Yagarto GNU ARM toolchain which is also great and free. No matter which tool you select code will work on both. Lets 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 favorite choices, so we will grab this one too. Yagarto website has a nice tutorial on how to setup…

Continue reading

FreeRTOS on AVR with external RAM

AVR microcontrollers aren’t best choice to run FreeRTOS scheduler due to low RAM. Atmega128 has only 4K of RAM memory, so this limits FreeRTOS functionality to very basic. Anyway this can be solved by adding extra RAM connected to external memory interface. We have already implemented external memory block of 8K previously so now we can muck around. Lets continue with our previous code having several simple tasks (button state reading, LCD output and LED flash), and add more to it. We are going to set up external RAM for storing heaps. This will allow to store large data buffers without worrying of heap and stack overlap.

Continue reading

Running multiple FreeRTOS tasks on AVR

In previous post we just run a single task. Running RTOS with single task has no meaning at all. This can be easily done with conventional program. But what if we need to have more separate functions. To execute them at exact timing would require separate timer or interrupt. But microcontroller cannot guarantee an interrupt for every tasks. This way it is hard to make code modular and testing can be painful. Using RTOS solves this kind of problem. It allows programming each task as endless loop. Kernel scheduler takes care of assuring each task gets it’s chunk of processing time. Additionally it does bearing the priority systems – more important tasks are executed prior to less important ones. Let us go further with our example code and add more tasks to our FreeRTOS engine. We already have LED flashing task that toggles LED every second. Additionally we are going…

Continue reading

Using FreeRTOS kernel in AVR projects

FreeRTOS is known as Real Time Operating System. Probably it would be too dare call it real-time-os, rather a real time scheduler where applications can be split in to independent tasks that share full processor resources by switching them rapidly it looks like all tasks are executed in parallel. This feature is called multitasking. There are lots of debates on using RTOS on AVR microcontrollers as they are arguable too small for running scheduler. The main limitation is small amount of ram and increased power usage. If you are gonna use lots tasks in application, probably you will run out of ram that is used for saving context when switching between tasks. Consider FreeRTOS only if you use larger scale AVRs like Atmega128 or Atmega256. Surely you can find smaller schedulers that are specially designed for smaller microcontrollers even tiny series. In other hand if you master FreeRTOS it can…

Continue reading

Getting hands on Arduino Ethernet Shield

  Updated! Arduino Ethernet code Since last Arduino Ethernet code there we several Arduino IDE releases with changes that affected the code listed in this post. Due high interest, we updated it with minor changes that makes it work as expected. The biggest occurred because Wstring.h library isn’t no longer in use, because String.h library is included in core that brings some difference in several functions used in code. In code we need to write readString += c; instead readString.append(c); if(readString.indexOf(“L=1”) >0) instead if(readString.contains(“L=1”)) Also we need to re-import Ethernet.h library in order to bring along all necessary libraries like Client.h, Server.h, SPI.h, Udp.h. The other problem occurred when program run was that LED actually never lights up when checkbox is selected. I used Serial.print(c); to track down the problem. And it seems that method GET sends two strings: Our code was catching and analyzing both strings. We only need…

Continue reading