In previous part of tutorial we have covered simple USART routines that sends data directly to USART peripheral. This is OK to use such approach when project isn’t time critical and processing resources are far from limits. But most often we stuck with these limiting factors especially when RTOS is used or when we perform critical real time data processing. And having USART routines with while loop based wait isn’t a good idea – it simply steals processing power only to send a data. As you may guessed – next step is to employ interrupts. As you can see there are many sources to trigger interrupts and each of them are used for different purpose. In order to use one or another interrupt first it has to be enabled in … Continue reading
When we need some feedback from microcontroller usually we use USART. It allows to output messages, debug information to terminal screen. Also data can be sent to MCU same way. For this purpose STM32 microcontrollers have more than one USART interface allowing to have multiple streams of data output and input. USART interface is designed to be very versatile allowing to have lots of modes including LIN, IrDA, Smart card emulation, DMA based transmissions. But for now lets focus on standard USART communications we we could send and receive messages from terminal window.
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 starting point of stack pointer): Each exception vector holds four byte wide address of service routine that is called when exception occurs. Exception table usually is located in startup code like this:
Previously we learned how to compile STM32VL Discovey projects that are included in package. But in order to understand how to write own programs we need to get to some basics. I think best place to start is input and output system (I/O). Before we begin to write some code lets go through whats in side STM32 ports. I you look in to STM32 reference manual you’ll find that I/O system is pretty flexible. Port pins are able to work in several modes: Input floating; Input pull-up; Input pull-down; Analog; Output open drain; Output push-pull; Alternate function push-pull; Alternate function open drain. Pins are organized as 16 bit ports that have their names like PORTA, PORTB, PORC, PORTD… Despite the fact that ports are 16-bit wide they are controlled with … Continue reading
In this tutorial we will set up a simple template for progamming ST32 -Discovery baord. For this we are going to use 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 own linker, startup and make scripts. For this we are going to use Michael Fischers 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 project name, select … Continue reading