找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

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

基于位操作的stm32f103流水燈程序

[復(fù)制鏈接]
ID:812531 發(fā)表于 2021-2-16 20:45 | 顯示全部樓層 |閱讀模式
  1. #include "stm32f10x.h"
  2. #include"led.h"
  3. #include"delay.h"
  4. int main()
  5. {
  6. LED_Init();
  7.         delay_init();
  8. while(1)
  9. {
  10. PBout(5)=1;
  11. PEout(5)=1;       
  12.         delay_ms(500);
  13.         PBout(5)=0;
  14. PEout(5)=0;       
  15.         delay_ms(500);
  16. }
  17.        
  18. }
復(fù)制代碼

  1. #include "led.h"

  2.           

  3. //初始化PB5和PE5為輸出口.并使能這兩個(gè)口的時(shí)鐘                    
  4. //LED IO初始化
  5. void LED_Init(void)
  6. {

  7. GPIO_InitTypeDef  GPIO_InitStructure;
  8.        
  9. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOE, ENABLE);         //使能PB,PE端口時(shí)鐘
  10.        
  11. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;                                 //LED0-->PB.5 端口配置
  12. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;                  //推挽輸出
  13. GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;                 //IO口速度為50MHz
  14. GPIO_Init(GPIOB, &GPIO_InitStructure);                                         //根據(jù)設(shè)定參數(shù)初始化GPIOB.5
  15. GPIO_SetBits(GPIOB,GPIO_Pin_5);                                                 //PB.5 輸出高

  16. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;                             //LED1-->PE.5 端口配置, 推挽輸出
  17. GPIO_Init(GPIOE, &GPIO_InitStructure);                                           //推挽輸出 ,IO口速度為50MHz
  18. GPIO_SetBits(GPIOE,GPIO_Pin_5);                                                  //PE.5 輸出高
  19. }

復(fù)制代碼



跑馬燈函數(shù) 位操作.7z

177.39 KB, 下載次數(shù): 18, 下載積分: 黑幣 -5

德飛萊STM32開(kāi)發(fā)板M3S V2.3電路圖.pdf

380.35 KB, 下載次數(shù): 9, 下載積分: 黑幣 -5

回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

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

快速回復(fù) 返回頂部 返回列表