当前位置:网站首页>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,还是很容易上手的!
边栏推荐
- 简单排序(暑假每日一题 14)
- Promise solves blocking synchronization and turns asynchronous into synchronous
- DHCP服务详解
- 织梦内核电动伸缩门卷闸门门业公司网站模板 带手机版【站长亲测】
- Presto中broadcast join和partition join执行计划的处理过程
- 【原创】启动Win10自带的XPS/OXPS阅读器
- P3384 【模板】轻重链剖分/树链剖分
- 小甲鱼汇编笔记
- Rongyun "Audio and Video Architecture Practice" technical session [complete PPT included]
- There are n steps in total, and you can go up to 1 or 2 steps each time. How many ways are there?
猜你喜欢

Flask框架初学-05-命令管理Manager及数据库的使用

关联接口测试

持续投入商品研发,叮咚买菜赢在了供应链投入上

Continuing to pour money into commodities research and development, the ding-dong buy vegetables in win into the supply chain

Snake game bug analysis and function expansion

Taurus.MVC WebAPI 入门开发教程1:框架下载环境配置与运行(含系列目录)。

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

织梦响应式酒店民宿住宿类网站织梦模板(自适应手机端)

DHCP服务详解

持续投入商品研发,叮咚买菜赢在了供应链投入上
随机推荐
DDTL:远距离的域迁移学习
(cf)Codeforces Round #811 (Div. 3)A--E详细题解
HBuilderX的下载安装和创建/运行项目
脚手架内容详解分析
Web APIs BOM- 操作浏览器:swiper 插件
持续投入商品研发,叮咚买菜赢在了供应链投入上
2022.8.3-----leetcode.899
工程制图名词解释-重点知识
2022广东省安全员A证第三批(主要负责人)考试题库及模拟考试
Good bosses, please ask the flink CDC oracle to Doris, found that the CPU is unusual, a run down
this巩固训练,从两道执行题加深理解闭包与箭头函数中的this
lombok注解@RequiredArgsConstructor的使用
JS 保姆级贴心,从零教你手写实现一个防抖debounce方法
Example 037: Sorting
0.1 前言
There are n steps in total, and you can go up to 1 or 2 steps each time. How many ways are there?
贪吃蛇游戏Bug解析及功能扩展
Zabbix设置邮件告警+企业微信告警
深度学习(三)分类 理论部分
织梦内核电动伸缩门卷闸门门业公司网站模板 带手机版【站长亲测】