The Way of the Register Source Code Update
I have recently been discussing a problem running one of the examples in this series on the STM8S Discovery board. After what seems like an eternity the problem was finally traced to the channel I was using in one of the timer examples. It turns out that Timer 1, channel 3 is connected to the touch sensor on the STM8S Discovery board. This means that the code does not generate the expected output. Credit for discovering this goes to Netduino Forum members Fabien and Gutworks.
This discussion also highlighted the fact that these samples were being used on two common development platforms, namely the Variable Labs Protomodule and the STM8S Discovery board. I have therefore modified the samples in order to support these platforms (where possible) as well as the development platform I am using. I will also be adding a compatibility table at the end of each post in the series to show which platforms on which the code has been tested.
Source Code
The following shows the current status of the sample code for the first nine articles in this series:
- Simple GPIO
Tested with: STM8S103F3, Protomodule, STM8S Discovery - Configuring the System Clock on the STM8S
Tested with: STM8S103F3, Protomodule, STM8S Discovery - External Interrupts on the STM8S
Tested with: STM8S103F3, Protomodule, STM8S Discovery - Using the UART on the STM8S Microcontroller
Tested with: STM8S103F3, Protomodule, STM8S Discovery - Generating a Regular Pulse Using Timer 2
Tested with: STM8S103F3, Protomodule, STM8S Discovery - Generating a PWM signal on the STM8S
Tested with: STM8S103F3, Protomodule, STM8S Discovery - Single Pulse Generation with the STM8S
Tested with: STM8S103F3, Protomodule, STM8S Discovery - Timer 1 Counting modes
Tested with: STM8S103F3, Protomodule, STM8S Discovery - Single conversion ADC on the STM8S
Tested with: STM8S103F3, Protomodule, STM8S Discovery
You can download the latest sources in a single zip file.
In making the changes to make the programs run on as many of the platforms as possible I also standardised the outputs to make them as compatible across the platforms where possible. So the following changes have been made:
- Port D pin 4 has been used where possible for all programs with a single output.
- Timer 1, Channel 3 has been changed to Timer 1, Channel 4 as the pin used for this output channel as Timer 1, Channel 3 is connected to the touch sensor on the STM8S Discovery board.
- The UART example uses UART1 on the STM8s130F3 and Protomodule but UART2 on the STM8S Discovery board.
- The ADC example uses AIN4 on the STM8S103F3 and STM8S Discovery board but AIN3 on the Protomodule.
Directory Layout
All of the projects use a similar directory structure. Let’s look at the first article in the series (Simple GPIO) as an example.
Unzip the file and navigate to the main directory, if you have used the default setting when extracting the files it should be 1 – Simple GPIO.
The main directory should contain three subdirectories (Discovery, Protomodule and STM8S103F3) and a single file (main.c).
main.c
This file contains the source code for this example and it is shared by all of the projects. Future examples may contain more files here in which case each file will also be a common file to all of the projects.
Discovery, Protomodule and STM8S130F3 Directories
These directories contain the workspaces and projects for each of the target platforms. They will also contain any code which is specific to that platform. At the time of writing the following platforms are supported:
- STM8S103F3 – STM8S103F3 TSSOP20 platform (my reference platform)
- Protomodule – Variable Labs Protomodule
- Discovery – STM8S Discovery board
Tags: Electronics, Software Development, STM8, The Way of the Register
Sunday, October 7th, 2012 at 7:12 pm • Electronics, Software Development, STM8 • RSS 2.0 feed Both comments and pings are currently closed.