当前位置:网站首页>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,还是很容易上手的!
边栏推荐
- 一个注解替换synchronized关键字:分布式场景下实现方法加锁
- [QNX Hypervisor 2.2 User Manual] 10.3 vdev gic
- Development of Taurus. MVC WebAPI introductory tutorial 1: download environment configuration and operation framework (including series directory).
- Sky map coordinate system to Gaode coordinate system WGS84 to GCJ02
- 网页三维虚拟展厅为接入元宇宙平台做基础
- 实例037:排序
- 编写 BOLL 心得体会
- 【指针内功修炼】深度剖析指针笔试题(三)
- Security First: Tools You Need to Know to Implement DevSecOps Best Practices
- Promise 解决阻塞式同步,将异步变为同步
猜你喜欢
工程制图平面投影练习
Parquet encoding
priority_queue元素为指针时,重载运算符失效
2022年茶艺师(中级)考试试题模拟考试平台操作
pytorch applied to MNIST handwritten font recognition
Example 035: Setting the output color
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
HBuilderX的下载安装和创建/运行项目
html select tag assignment database query result
C程序编译和预定义详解
随机推荐
QNX Hypervisor 2.2用户手册]10.2 vdev 8259
Oracle迁移到瀚高之后,空值问题处理
Day13 Postman的使用
小甲鱼汇编笔记
云开发旅游打卡广场微信小程序源码(含视频教程)
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
There are n steps in total, and you can go up to 1 or 2 steps each time. How many ways are there?
Parquet encoding
织梦响应式酒店民宿住宿类网站织梦模板(自适应手机端)
sudo 权限控制,简易
esp32发布机器人电池电压到ros2(micro-ros+CoCube)
Simple sorting (summer vacation daily question 14)
initramfs详解----添加硬盘驱动并访问磁盘
Security First: Tools You Need to Know to Implement DevSecOps Best Practices
织梦内核电动伸缩门卷闸门门业公司网站模板 带手机版【站长亲测】
【原创】启动Win10自带的XPS/OXPS阅读器
html select tag assignment database query result
Rongyun "Audio and Video Architecture Practice" technical session [complete PPT included]
实例041:类的方法与变量
云开发校园微社区微信小程序源码/二手交易/兼职交友微信小程序开源源码