Like an Arduino Nano just enough circuit to get you going. We need to program through the SWIM interface pins until we add a bootloader to program on USB. More on theboard.
Contain versions of the STM8S MCU microcontroller unit from Thompson Semiconductor corporation. This chip has 1kB RAM and 8kB flash memory for programs. An 8bit processor it is comparable to an ATtiny or 8051 chip.
The boards are listed as STM8S003F3P6, STM8S103F3 and STM8S103K3T6. Specifications are the same, programs compile same for both. LED pin B5 for the little board and pin C3 for the big one.
SWIM Programming InterfaceTo upload your compiled binary executable program you need an ST-Link programmer device. We'll use an inexpensive ST-LinkV2. The SWIM pins are for STM8 and SWD is for other chips.
Look closely at the label printed on the programmer and the pins. Connect RST-SWIM-GND-3v3. You can power some boards from the ST-Link.
Open Arduino IDE and create a new sketch. Enter this code and save. It uses keywords for STM8 IO circuits and will not compile until we are properly configured.
// STM8S blink Sduino ST-Link/V2
void setup() {
GPIOA->DDR = 0XFF;GPIOB->DDR = 0XFF;GPIOC->DDR = 0XFF;
GPIOD->DDR = 0XFF;GPIOE->DDR = 0XFF; // all ports output
}
void loop() {
--GPIOA->ODR;GPIOB->ODR++;GPIOC->ODR--;
GPIOD->ODR++;GPIOE->ODR--; // toggle all IO ports
{int n = 20000; while(n-- >0);} // nop loop
}
The code turns on all IO pins of 5 GPIO ports as output. Each pin is toggled and we expect one built-in LED on our development board. Choose delay n and decrement to zero.
PreferencesMenu File->Preferences or Ctrl+comma from the keyboard.
The Additional Boards Manager URL Universal Resource Locator is a file repository on the web. Tick the boxes for Show verbose output. Select a comfortable font size.
The URL is https://github.com/tenbaht/sduino/raw/master/package_sduino_stm8_index.json you need to click OK to save. You can visit this github repository online for more information.
Install Sduino CoreWe're going to add software packages to our basic Arduino installation. Sduino is provided by an interested party. Menu Tools->Board:->Boards Manager..
Search the Boards Manager pop-up for STM8 and install Sduino. It will take a moment to download and install the new packages.
Menu Tools->Board:->STM8S Boards and select the STM8S103F3 Breakout Board.
Use the menus to select ST-Link/V2. More info on setup and using ST-Link programmer with STM8 devboards.
Carefully locate the four programming pins on your USB dongle: RST, SWIM, GND and 3.3Volts. Some boards will power up from the dongle, some need power through USB.
Upload the sketch normally and you should see progress at the bottom of the screen. We do not need to upload using programmer. Export compiled Binary generates a hex file that you can upload.
Upload normally. Arduino knows it's supposed to use the ST-Link V2 USB dongle. Change delay value to change blink speed.
We downloaded a software package containing program files that convert the Arduino IDE into a development environment for STM8 processors. We selected verbose output so that we can look at the build messages.
Our toolchain is SDCC small device C compiler used to build a.hex file. Plus other programs from the suite to compile for 8051, pic, STM and other processors.
We can write sketches that access the SPL Standard Peripheral Library from Thomson Semiconductor. The library is open source and you can copy any file you need into your projects. As you experiment with STM8 chips you can borrow these files to use with other tools.
There are a lot of model numbers in the product line. They mostly have the same flash, RAM, clock and other vital statistics. It is easy to try a different device and see if it works.
We don't have to uncomment the MCU choice. Many other coding projects will need you to uncomment #define STM8S103 but Arduino passes a switch value. Find out how and you can program more processors.
The firmware upload is performed by the stm8flash.exe application. We see that in an Arduino flash upload screencapture because we selected verbose output.
Slide the output window up and down or side to side to read all the messages. It tells us how a file SduinoStm8.ino.hex is uploaded with program stm8flash with circuit stlinkv2 to part stm8s103.
Probably not. These chips do not have much flash. Bootloader programs let you program your board through the USB connector like an Arduino. You can power your board through USB and it may be connected to IO ports with resistors.
Comments
Please log in or sign up to comment.