国产免费AV|泡泡玛特欧洲总部将设在伦敦|中文天堂网www新版资源在线|一本久道综合在线中文|国精产品一二三产区的使用方法|香蕉鱼在线观看|www.27eee

 找回密碼
 注冊
搜索

proteus仿真STM32 GPIOC口分別接有一個開關K1和兩個指示燈 兩個燈一亮一滅

[復制鏈接]
樓主
路漫漫 發表于 2020-6-10 23:30:01 | 只看該作者 |只看大圖 |倒序瀏覽 |閱讀模式
proteus仿真STM32 GPIOC口分別接有一個開關K1和兩個指示燈 兩個燈一亮一滅
c語言程序和仿真文件.7z (60.48 KB, 售價: 1 E幣)
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
proteus仿真STM32 GPIOC口分別接有一個開關K1和兩個指示燈 兩個燈一亮一滅 1.png
本程序以stm32f10x為核心
部分源碼:
  1. #include"stm32f10x.h"
  2. voidGPIO_Config(void);
  3. intmain(void)
  4. {   
  5.    
  6.     int i;
  7.     GPIO_Config();
  8.     GPIO_SetBits(GPIOC, GPIO_Pin_5);  
  9.      GPIO_ResetBits(GPIOC, GPIO_Pin_6);
  10.     while(1)
  11.     {
  12.             if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_10)==0)
  13.             {
  14.                 for(i=0;i<500;i++){}
  15.                    if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_10)==0)
  16.                    {
  17.                        GPIO_WriteBit( GPIOC,GPIO_Pin_5, (BitAction)(1 - GPIO_ReadOutputDataBit( GPIOC, GPIO_Pin_5 )));
  18.                        GPIO_WriteBit( GPIOC,GPIO_Pin_6, (BitAction)(1 - GPIO_ReadOutputDataBit( GPIOC, GPIO_Pin_6 )));
  19.                        while(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_10)==0);
  20.                    }
  21.          
  22.          }
  23.      }
  24.      
  25. }
  26. voidGPIO_Config(void)
  27. {
  28.    
  29.   GPIO_InitTypeDef GPIO_InitStructure;
  30.   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE) ;
  31.     GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  32.     GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
  33.     GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6|GPIO_Pin_5;
  34.     GPIO_Init(GPIOC,&GPIO_InitStructure);
  35.     GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;
  36.     GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
  37.     GPIO_Init(GPIOC,&GPIO_InitStructure);
復制代碼


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

本版積分規則

手機版|小黑屋|ELEOK |網站地圖

GMT+8, 2026-5-26 03:07

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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