For a few months now I have been writing a series of blog posts on using the STM8S chip with the aim that I may actually get to the point where I can show how to develop a module using the chip. The series has been titled The Way of the Register since I had a few problems with the STD Peripheral Library produced by ST and moved on to direct register access on the chip. Each article in the series takes a distinct task and describes how to achieve the task using the STM8S. Where possible, full project and source code for the IAR environment is included. All of these examples use the STM8S103F3 chip. If you are using other chips (say the STM8S Discovery Board) then you will also want to have a look at the post on Converting The Way of The Register Examples in order to work out what you will need to do in order to convert these examples. You can find the series on The Way of the Register page. I have covered the following topics so far:
Converting STD Library Code to use Direct Register Access on the STM8S
Going from using the STD Peripheral Library on the ST processors can be a little bewildering. This article attempt to guide you through the process of converting you code from using the STD Peripheral library to using registers.
Toggle a single GPIO line to produce an approximate square wave signal.
Configuring the System Clock on the STM8S
Configure the system clock to use the internal HSI oscillator running at 16MHz. Generate a square wave signal using a GPIO line and show how the frequency of the square wave can be changed by manipulating the clock divider.
External Interrupts on the STM8S
Capturing user input through a switch using the STM8S.
Using the UART on the STM8S Microcontroller
Learn how to setup and use the serial port on the STM8S to generate debug information or control serial devices.
Generating a regular signal using Timers
Here we will learn how to use one of the timers on the STM8S to generate a square wave signal.
Generating a PWM signal on the STM8S
In this article we look at generating a PWM signal using channel 1 of Timer 2 on the STM8S.
An overview of how interrupts works on the STM8S
Single Pulse Generation and Timer 1 Counting Modes These two articles take a look at Timer 1 and show how to generate a single pulse of a known length and also suggest some modifications which can be made as a exercise to show the different counting modes available on this timer.
Setup the ADC to perform a single conversion and then use that value to control the properties of a PWM signal and hence control the brightness of the LED. I have also converted a number of the sample programs to us not only my own reference platform but also the Variable Labs Protomodule and the STM8S Discovery boards.
This post sets up SPI on the STM8S using hardware chip select. The data exchange is restricted to single bytes.
This post adds buffering to the SPI data exchanges and uses software controlled chip select to determine when data transfer should be started.
STM8S SPI Slave (Part 3) - Making a Netduino Go Module Building on the previous two SPI posts, this one implements a simple GoBus comms protocol allowing module developers to create simple modules using the STM8S.
Transmitting Data Using SPI Master Mode
Using the master mode of the SPI interface on the STM8S to control the brightness of 16 LEDs connected to the TLC5940 16-channel PWM controller IC.
Storing Data in EEPROM on the STM8S
Writing a small amount of data in the EEPROM area of the STM8S in order that the data can survive a device reset or loss of power.
Using the Auto-Wakeup Feature on the STM8S Discovery Board
Using the Auto-Wakeup feature after a predefined time period of up to 30s.
Adding an independent watchdog to detect software failure/locks.
Using the Beep function to generate signals from 50Hz to 32KHz.
Detecting software failure using the Window Watchdog function.
Reading the temperature on a TMP102
Creating a simple I2C salve device
Hope that you find this useful,
Mark
Edit: Converted the headings into links to the original posts.
Edit: 8th Oct 2012 - Added details on four additional posts.
Edit: 19th Nov 2012 - Added details about two SPI posts.
Edit: 26th Nov 2012 - Add the Module post link and information.
Edit: 1st Dec 2013 - Added links to two new posts, SPI master data transmission and storing data in EEPROM.
Edit: 20th Jun 2014 - Added a link to the Auto-Wakeup article
Edit: 21 June 2014 - Added link to Watchdog post.
Edit 5 August 2016 - Added additional samples.
Edited by Nevyn, 05 August 2016 - 05:38 AM.