找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1771|回复: 0
打印 上一主题 下一主题
收起左侧

CHSF103C8T6单片机点亮led

[复制链接]
跳转到指定楼层
楼主
ID:277948 发表于 2021-3-25 10:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
CHSF103C8T6为国产32位单片机,性能也挺好,可部分代替说stm32F103C8T6。
本次程序为点亮led:
  1. //io引脚配置
  2. #include "led.h"

  3. //LED IO初始化
  4. void LED_Init(void)
  5. {

  6. GPIO_InitTypeDef  GPIO_InitStructure;
  7.          
  8. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);         //使能PB,PE端口时钟
  9.         
  10. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;                                 //LED0-->PB.5 端口配置
  11. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                  //推挽输出
  12. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                 //IO口速度为50MHz
  13. GPIO_Init(GPIOC, &GPIO_InitStructure);                                         //根据设定参数初始化GPIOB.5
  14. GPIO_SetBits(GPIOC,GPIO_Pin_13);                                                 //PB.5 输出高
  15. }


  16. #include "delay.h"
  17. #include "sys.h"
  18. #include "led.h"
  19. #include "timer.h"

  20. int main(void)
  21. {
  22.         u16 t;
  23.         delay_init();
  24.         LED_Init();
  25.         while(1)
  26.         {
  27.                 LED0=0;
  28.                 delay_ms(1000);
  29.                 LED0=1;
  30.                 delay_ms(1000);
  31.         }
  32. }



复制代码

{

GPIO_InitTypeDef  GPIO_InitStructure;
         
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);         //使能PB,PE端口时钟
        
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_13;                                 //LED0-->PB.5 端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                  //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                 //IO口速度为50MHz
GPIO_Init(GPIOC, &GPIO_InitStructure);                                         //根据设定参数初始化GPIOB.5
GPIO_SetBits(GPIOC,GPIO_Pin_13);                                                 //PB.5 输出高
}

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表