1. Open STVD, File->New Workspace;
2. Double-click Create workspace and project, and enter the name of the workspace in the Workspace filename column. It can be in Chinese or English with spaces. Enter the path of the workspace in the Workspace location column. As shown in the figure below, first find the desktop path in the browse folder, and then click the New Folder button on the right to create a folder. Or directly select an existing path. Click OK;
3. Enter the name of the project in the Project filename column, select STM8 Cosmic as the compiler in the Toolchain drop-down menu, and click OK;
4. Enter STM8S105K4 or 105K4 in the Show MCUs containing column, click the Select button in the lower left corner, and click OK.
At this point, the workspace and project have been created. The project contains the following files: main.c, stm8_interrupt_vector.c in the Source Files folder, and mods0.h in the External Dependencies folder.
In the initial stage, before we learned program modularization, the program code was written in the source file main.c (the source file is the file name.c document).
Find the two header files STM8S105K.h and STM8S105K4.h in the C:\Program Files (x86)\STMicroelectronics\st_toolset\include folder, copy and paste them in the root directory of the project, such as the C:\Users\HuHongYu\Desktop\Demo folder in this example.
In the main.c file, write the following code above the main() function.
#include
#include is a keyword in C language, which is used to include header files. STM8S105K4.h is a header file (i.e. file name.h document). This header file declares the address of the microcontroller register. When compiling the program, programming the register means operating the corresponding address of the register in the microcontroller flash. So we need to include this header file in main.c.
C language distinguishes between uppercase and lowercase letters. Except for strings and comments, all codes must be entered in English input method.
The third row of the menu bar has three buttons: the first is Compile, which compiles the current file code; the second is Build, which compiles the modified document and its associated documents; the third is Rebuild All, which recompiles all documents in the project. In the future, we will mainly use the second button Build.
After clicking the Build button, the following prompt box appears, select Yes To All.
The Build window below shows demo.elf - 0 error(s), 0 warning(s), which means that after the compilation is successful, the header files copied from the ST installation path will appear in the External Dependencies folder. Because STM8S105K.h is included in STM8S105K4.h, the latter is also included in the project after compilation.
There are two buttons in the third row of the menu bar. The first one is Start Debugging, which is used to download the compiled program to the microcontroller for simulation. The second one is Stop Debugging, which is used to exit the simulation.
Before downloading the simulation program, first connect the 3.3V, SWIM, GND, and RST pins of the ST-LINK V2 (downloader) to the VCC (3.3V), SWIM, GND, and NRST pins of the STM8 microcontroller. VCC is the power supply (positive power supply), and GND is the ground (negative power supply).
Click the Debug button. If error 40201 appears, open C:\Program Files (x86)\STMicroelectronics\st_toolset\stvd\dao and install the ST Toolset.msi file.
When you exit STVD, the following two prompt boxes will appear. Select Yes. These two prompt boxes will appear every time you create a new project.
To open the STM8 program project in the future, find the workspace name .stw in the project folder and double-click to open it. If it cannot be opened, use the following two methods:
1. Left-click and select the ***.stw file, drag it to the STVD desktop shortcut icon, and overlap it to open it directly;
2. Open STVD, select File->Open Workspace from the menu bar, and open the ***.stw file.
Previous article:Experiment 1: Building a development environment
Next article:Experiment 3 Lighting up an LED
Recommended ReadingLatest update time:2024-11-23 12:01
- Popular Resources
- Popular amplifiers
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- GD32L233C running RT-Thread Nano
- Common FPGA debugging techniques
- [ESP32-S2-Kaluga-1 Review] Use of the console component
- Simulation study on dynamic performance of 200km/h EMU
- Communication failure
- Simple Measurement of Operational Amplifiers
- Classic river crossing puzzle game
- How to Use Multimeter to Measure Ground Resistance
- Pirated copies are really hard on the eyes - do you feel the same?
- How to modify this H-bridge motor drive circuit so that the MOS tubes of the upper and lower bridge arms will not be turned on at the same time