找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2461|回復: 0
收起左側(cè)

CHSF103C8T6單片機點亮led

[復制鏈接]
ID:277948 發(fā)表于 2021-3-25 10:23 | 顯示全部樓層 |閱讀模式
CHSF103C8T6為國產(chǎn)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);                                         //根據(jù)設(shè)定參數(shù)初始化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);                                         //根據(jù)設(shè)定參數(shù)初始化GPIOB.5
GPIO_SetBits(GPIOC,GPIO_Pin_13);                                                 //PB.5 輸出高
}

回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復 返回頂部 返回列表