当前位置:网站首页>STM8S105k4t6c--------------点亮LED
STM8S105k4t6c--------------点亮LED
2022-08-04 02:20:00 【挨踢玩家】
上一篇文章写了STM8S项目创建
这篇来点亮stm8s的板载LED
因为我的板子上的测试LED是PE5脚,你们根据自己的来改下代码就完事
1.打开创建好的工程项目
像我这样写就好了
main.c代码文件
#include "stm8s_conf.h"
#include "led.h"
#include "sysclk.h"
#include "stm8s_it.h"
#include "iostm8s105.h"
#include "stm8s.h"
void System_Init(void)
{
SysHSICLK_Config();//时钟配置初始化
LED_Config();
}
void main(void)
{
System_Init();
while (1)
{
;
}
}
led.c代码文件
#include "led.h"
#include "iostm8s105.h"
void LED_Config(void)
{
GPIO_Init(LED_GPIO_PORT, LED_GPIO_PIN, GPIO_MODE_OUT_PP_HIGH_FAST);
LED_On;
}
**
led.h代码文件
**
#ifndef __LED_H
#define __LED_H
#include "stm8s_conf.h"
#define LED_GPIO_PORT GPIOE
#define LED_GPIO_PIN GPIO_PIN_5
#define LED_On GPIO_WriteLow(LED_GPIO_PORT, LED_GPIO_PIN)
#define LED_Off GPIO_WriteHigh(LED_GPIO_PORT, LED_GPIO_PIN)
void LED_Config(void);
#endif
**
**
烧录
**
这样对应来接就好了。
ST-LINK2 —> STM8S
SWIM ------> SWIM
NRST-------> NRST
VCC--------> VCC
GND-------->GND
现象:LED亮了
烧录前 ↓
烧录后 ↓
总结:stm8s的IO口配置比stm32简单很多,没有时钟配置,没有结构体赋值再存入寄存器的操作。学过C51,还是很容易上手的!
边栏推荐
- What is the source of flinkcdc consuming mysql binlog data without sqltype=delete
- 贪吃蛇游戏Bug解析及功能扩展
- 共n级台阶,每次可以上1级或2级台阶,有多少种上法?
- Download install and create/run project for HBuilderX
- this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
- The browser
- 什么是SVN(Subversion)?
- 实例036:算素数
- 深度学习(三)分类 理论部分
- Development of Taurus. MVC WebAPI introductory tutorial 1: download environment configuration and operation framework (including series directory).
猜你喜欢
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
Download install and create/run project for HBuilderX
Zabbix设置邮件告警+企业微信告警
DDTL: Domain Transfer Learning at a Distance
工程制图平面投影练习
idea中diagram使用
Utilities of Ruineng Micrometer Chip RN2026
Instance, 038: the sum of the diagonal matrix
Development of Taurus. MVC WebAPI introductory tutorial 1: download environment configuration and operation framework (including series directory).
随机推荐
出海季,互联网出海锦囊之本地化
esp32 releases robot battery voltage to ros2 (micro-ros+CoCube)
工程制图复习题(带答案)
第13章 网络安全漏洞防护技术原理与应用
v-model
Example 041: Methods and variables of a class
参加Oracle OCP和MySQL OCP考试的学员怎样在VUE预约考试
可变字符串
splice随机添加和删除的写法
Flask框架初学-05-命令管理Manager及数据库的使用
Day13 Postman的使用
Ant - the design of the Select component using a custom icon (suffixIcon attribute) suffixes, click on the custom ICONS have no reaction, will not display the drop-down menu
云开发校园微社区微信小程序源码/二手交易/兼职交友微信小程序开源源码
sudo 权限控制,简易
sql有关问题,小时粒度,找到前一个小时内的数据
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
MallBook 助力SKT思珂特教育集团,立足变化,拥抱敏捷交易
Example 037: Sorting
Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain
一篇文章看懂JS闭包,从执行上下文角度解析有趣的闭包