As you can see, I have also connected my ST-link programmer to programming pins which will not only program our board but will also act as a power source. My hardware set-up for this tutorial is shown below. The on-board Led is already connected to PB5 (pin5 of PORTB), so I have just connected an LED to PA3 and a push-button to PA2, as you can see in the diagram below.īut, of all the output pins available on our controlled why did I select PA3 for output and PA2 for input? The questions are valid and I will explain that later in this article. The idea is to learn all the GPIO functionality in a simple set up. As mentioned early, we will be using two LEDs here, one is an onboard LED which will blink continuous and the other is an external LED which will be toggled with a push button. Getting the Hardware Readyīefore we dive into the program, let get the hardware connections ready. If you are completely new, it is highly recommended to read the previous tutorial before you proceed any further.
#Stm8 cosmic download how to#
The board already has an onboard LED connected to pin 5 of port B, we will learn how to blink this LED and also add an external LED and control it with a push-button. In this tutorial, we will learn how to perform general GPIO functions on STM8S controllers. With all the basics covered, lets actually start writing code. We have also learned how to use the standard peripheral libraries, and how to compile and upload the code into our microcontroller.
In our previous tutorial, we learned how to get started with STM8S103F3 Development Board and how to set up the IDE and compiler to program our STM8S controllers.
For microcontrollers, an LED blinking program is equivalent to the “hello world” program.