Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

STM32 interrupts and programming with GCC

Probably one of the key features in any microcontroller is interrupt system. ARM Cortex-M3 microcontrollers may have up to 256 interrupts sources. First 15 interrupt sources are called system exceptions. These exceptions rise within Cortex core like reset, NMI, hard fault and error, debug and SystTick timer interrupt. In the exception table, they start from address 0x00000004 and are numbered from 1 to 15. There is no 0 number exception (FYI – the very top of exception table address is used to store the starting point of stack pointer): Each exception vector holds the four-byte address of service routine that is called when an exception occurs. Exception table usually is located in startup code like this: Continue reading

ST32MVLDiscovery project template for GCC

In this tutorial, we will set up a simple template for programming ST32 -Discovery board. For this, we are going to use the latest Code Sourcery and Eclipse IDE. To make things simpler, we are going to use ARM-based 32-bit MCU STM32F10x Standard Peripheral Library v3.5.0 that can be downloaded from ST site. Also, we are going to use STM32VLDiscovery firmware package for example files. And why write our linker, startup and make scripts. For this, we are going to use Michael Fischer’s example project (STM32Test.zip) for yagarto. We only need small modifications to fit our needs. In this stage, we assume that you have set up Eclipse and Code Sourcery and we can go further. First of all, create new C project in Eclipse File->New: Enter the project name,… Continue reading

Programming STM32-Discovery using GNU tools. Startup code

Startup code is executed just after microcontroller is reset before the main program. As linker script, startup code usually is implemented as universal code for all the same microcontroller type. So often you don’t need to write one from scratch. Anyway, it is good to know what happens there anyway. As we said, linker script has to go along with the startup code. This means that it will initialize MCU automatically according to data defined in the linker. Startup code initializes variables, copies defined variables from Flash to RAM, initializes stack and then gives resources to the main program. You will find that startup codes usually are written in assembly language, but this can also be done in C which is easier to read and modify if necessary. First of… Continue reading

Programming STM32-Discovery using GNU tools. Linker script

Previously we went through setting up a development environment for ARM Cortex-M3 microcontroller. We decided that two equal choices will do same job – either CodeSourcery G++ Lite or Yagarto. Both use same base of GNU tool-set. Developing with GCC tools To get a working binary, there is a series of tools involved during code development. Several tools are necessary to compile simple applications. These are compiler, assembler, linker and binary generator. Each of them does its task in a chain process. When you start compiling your project usually there is a linker invoked, which with correct parameters links libraries, object files. Once executable is generated, then binary image generator creates binary image (.bin or .hex) that can be uploaded to MCU. We won’t go in to details right now… Continue reading