How to calibrate touch screen display on STM32 board

Touch screen displays are common choice in many microcontroller projects. Touch capability won’t take additional space – it sits on top of LCD where you can directly interact with objects you see on screen. In order to get this working touch screen coordinates must match screen coordinates. So could be sure when you touch the point on screen you point where you want.

Touch screen is analog device. It is made of two flexible resistive sheets with gap between. When screen is touched, a connection between sheets is made and thus measurement of voltage drop is taken. Normally resistive touch screen has four wire configuration. And normally there is a specialized IC used to take measurements and send data to MCU for processing. In our case we are dealing with ADS7843 touch screen controller, but in other systems this works pretty same way.

stm32_touch_screen_interface

The fact is that touch screen controller reads screen ADC values and simply passes them via SPI interface. So all you get is raw ADC readings that are not lined up with LCD coordinates. As you know LCD screens can be different resolution, different orientation, so data gathered from resistive touch screen must be scaled down to match all those circumstances. And this is done in different ways. One of the method I tried before was simple mathematical-empirical approach, when you know the ADC readings on screen edges. Then you can calculate what is ADC value per pixel size and thus calculate the coordinates using simple formula: (more…)

Learn Arm Cortex processor the easy way

Me, like most of you have been using smaller scale microcontrollers like AVR or PIC. These are great chips and you should keep working with them as long as they fit your needs. Eventually you getting to project where your loved chip simply cannot handle the load.

  • You need to run more complex code to do fancy things;
  • You must keep up with more complex interfaces;
  • Meet multimedia challenges;
  • Process more data in a shorter time.

Eventually you realize that you simply need faster and more modern microcontroller to work with. ARM Cortex is a number one choice. Like with all new stuff you may find it a bit frightening to start with new microcontroller. When I first started with ARM Cortex-M3 processor I was looking for some basic and easy to understand guide. I found and highly recommend a wonderful book about ARM Cortex-M3 CPU. Its called [The Definitive Guide to the ARM Cortex-M3, Second Edition]. This is great book written by Joseph Yiu.

Why start with a book, instead of hunting for scattered tutorials on the internet? Especially if you haven’t tried to work ARM microcontroller you may miss lots of features it has comparing to 8-bit micros. ARM Cortex has a pack of many great features that does job not even faster but takes less code space. It may seem that reading and understanding whats in it may be time consuming and boring, but it turned out that it took me to go through in a few hours and understand all aspects.

I highly recommend to get it and read it. It will help to squeeze the most of ARM Cortex-M3 processor in your next project. Don’t hesitate and get it now here:

The Definitive Guide to the ARM Cortex-M3 Second Edition

Flashing programs to STM32. Embedded Bootloader

There has been several requests among users to explain more about loading programs in to flash memory of STM32 microcontrollers.

This of course is a wide topic but lets focus on how to achieve result – flash program in to MCU. Depending on what arsenal is on your desk you can do in several different ways. Let’s try to go through them in practical way. (more…)

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 maximum 72MHz frequency and is considered to be a medium-density performance line microcontroller. Other features include USB, CAN, 7 timers, 2ADCs and 9 communication interfaces.

Development board has several nice features to get started with. First of all it has RS232 interface for communicating and accessing bootloader. There also is a USB 2.0 full speed interface connector that also can work as power supply. Next is a JTAG connector to program microcontroller using tools like J-Link adapter. Two push buttons and two progammable LEDs are hardwired to MCU pins alongside all I/Os connectors. (more…)