stvd version information: ST Visual Develop Version 4.3.9
Microcontroller model: stm8l051F3
Steps for establishing stm8l project with stvd:
1. Open stvd, File->New Workspace...
Select Create workspace and project
Enter the project name in Workspace filename, and the project storage path in Workspace location
Enter the project name in Project filename; enter the project storage path in Project location, and select the compiler to be used in Toolchain, here select STM8 Cosmic;
Toolchain root will automatically obtain the path of the compiler according to the selection of Toolchain
Select the IC model, double-click, and then click OK
Click OK, the preliminary project and project have been established, and the compilation is successful.
The stm8l_led project Source Files adds two files, main.c and stm8_interrupt_vector.c.
The led directory automatically adds main.c and stm8_interrupt_vector.c files.
2. Add the STM8L15x_StdPeriph_Driver standard library.
2.1. Copy the three files stm8l15x_conf.h, stm8l15x_it.h, and stm8l15x_it.c to the led directory.
2.2. Copy the STM8L15x_StdPeriph_Driver folder to the led directory.
2.2. Add stm8l15x_conf.h, stm8l15x_it.h, and stm8l15x_it.c to the stm8l_led project, and then add stm8l15x.h from the inc folder under STM8L15x_StdPeriph_Driver to the stm8l_led project.
2.3. Double-click to open stm8l15x.h and remove the comment symbol of the MCU model used.
The compilation project prompts an error:
Running Linker
clnk -m Debugstm8l_led.map -l"C:Program Files (x86)COSMICCXSTM8Lib" -o Debugstm8l_led.sm8 Debugstm8l_led.lkf
#error clnk Debugstm8l_led.lkf:68 Debugstm8_interrupt_vector.o: symbol f_NonHandledInterrupt multiply defined (Debugstm8l15x_it.o)
The command: "clnk -m Debugstm8l_led.map -l"C:Program Files (x86)COSMICCXSTM8Lib" -o Debugstm8l_led.sm8 Debugstm8l_led.lkf " has failed, the returned value is: 1
exit code=1.
Comment the @far @interrupt void NonHandledInterrupt (void) function in the stm8_interrupt_vector.c file because it is defined repeatedly. #include the "stm8l15x_it.h" header file and then compile it.
2.4. Select the stm8l_led project in the stvd software Workspace box, right-click and select New Folder... from the pop-up menu, and enter the name of the new folder STM8L15x_StdPeriph_Driver
2.5. In the stm8l_led project in the stvd software Workspace box, right-click STM8L15x_StdPeriph_Driver and select Add Files to Folder..., and select stm8l15x_gpio.c in the STM8L15x_StdPeriph_Driversrc directory.
2.6. Double-click to open the stm8l15x_conf.h file and comment out #define USE_FULL_ASSERT.
2.7. Change the content of main.c to the following code, compile the project, and compile successfully.
//STM8L051/151 and other series shared library functions
#include "stm8l15x.h"
//Define LED port
#define LED_PORT GPIOD
#define LED_PINS GPIO_Pin_0
/***********************************************************************************
****Entry parameters: None
****Export parameters: None
****Function Note: Inaccurate delay function
***********************************************************************************/
void Delay(__IO uint16_t nCount)
{
/* Decrement nCount value */
while (nCount != 0)
{
nCount--;
}
}
/***********************************************************************************
****Function description: Main function
****Entry parameters: None
****Export parameters: None
****Function Notes: LED flashes at a certain frequency
************************************************************************************/
void main(void)
{
GPIO_Init(LED_PORT, LED_PINS, GPIO_Mode_Out_PP_Low_Slow); //Initialize LED port
while (1)
{
GPIO_ToggleBits(LED_PORT,LED_PINS); //Flip LED port
Delay(50000);
}
}
At this point, a basic STM8l project has been created. If you need to use other module functions of the microcontroller, add them according to the method of adding stm8l15x_gpio.c. For example, if you want to use spi, add stm8l15x_spi.c to the project.
In addition, the process of establishing a stm8s project is similar to this.
Previous article:stvd+stm8l051F3: segment .bss size overflow (293)
Next article:stvd+stm8s: The Flash Memory Read-out protection option must be disabled
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- How do you pronounce “5G” in your native dialect?
- Playing with Zynq Serial 31——[ex53] EMIO control based on Zynq PS
- Great! Tektronix oscilloscopes have been completely upgraded, come and unlock them! If you don't read it, you will miss out on 100 million!
- TMS320C6000 Basic Learning (3)——CCS v5 Software Development Environment Construction
- Microcontrollers: The Basics
- 【Home Smart Dashboard】 Development and Construction of ESP-IDF under Linux
- [ESP32-S2-Kaluga-1 Review] 2. LCD display pictures
- 【Video Class】Introduction to Antenna Eigenmode Analysis
- Can't see the downloaded file
- 【AT-START-F425 Review】No.05 FLASH