找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1912|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

實驗4-2 GPIO_Test_2

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:415128 發(fā)表于 2018-11-18 13:50 | 只看該作者 |只看大圖 回帖獎勵 |倒序瀏覽 |閱讀模式
本帖最后由 zhou__mi 于 2020-6-22 19:12 編輯


程序代碼:
// 實驗程序分為3個部分或者說3個步驟:
//(1)RCC_Configuration 函數(shù)使能外設(shè)GPIO PORTC時鐘;
//(2)GPIO_Configuration函數(shù)設(shè)置PC6為50MHz推挽輸出;
//(3)GPIO_ResetBits庫函數(shù)設(shè)置PC6輸出低電平0,熄滅與PC6連接的LED1,
//        GPIO_SetBits  庫函數(shù)設(shè)置PC6輸出高電平1,點亮與PC6連接的LED1。
/***************************************************************************
* File Name          : main.c
* Author             : Zhou_yinxiang, 1881003@qq.com,CDUESTC
* Date First Issued  : 03/08/2014
* Description : 點亮 或 熄滅 與PC6連接的LED1
   使用ST的庫函數(shù),MDK4.7,最簡RCC配置,在AS-05(STM32-SS),AS-07,PROTEUS上驗證通過  
****************************************************************************/

/* Includes ---------------------------------------------------------------*/
#include "stm32f10x_lib.h"//包含頭文件

/* Private function prototypes --------------------------------------------*/
void RCC_Configuration(void);//函數(shù)聲明
void GPIO_Configuration(void);//函數(shù)聲明
        
/* Private functions ------------------------------------------------------*/

/***************************************************************************
* Function Name  : main
* Description    : Main program.
* Input          : None
* Output         : None
* Return         : None
****************************************************************************/
int main(void)//main函數(shù),在STM32F10x.s里,設(shè)置IMPORT  __main為程序的入口
{  
  /* Configure the system clocks */
        RCC_Configuration();//調(diào)用設(shè)置系統(tǒng)時鐘函數(shù)

  /* Configure the GPIO ports */
  GPIO_Configuration();//調(diào)用設(shè)置GPIO端口函數(shù)

        while(1)
  {
                //GPIO_ResetBits(GPIOC, GPIO_Pin_6); //PC6輸出低電平,熄滅LED1
                GPIO_SetBits(GPIOC, GPIO_Pin_6); //PC6輸出高電平,點亮LED1

        }   

}


/***************************************************************************
* Function Name  : RCC_Configuration
* Description    : Configures the different system clocks.
* Input          : None
* Output         : None
* Return         : None
***************************************************************************/
void RCC_Configuration(void)//設(shè)置系統(tǒng)時鐘函數(shù)
{  
  /* Enable GPIOA clocks */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);//使能GPIOC的時鐘
        
}


/**************************************************************************
* Function Name  : GPIO_Configuration
* Description    : Configures the different GPIO ports.
* Input          : None
* Output         : None
* Return         : None
***************************************************************************/
void GPIO_Configuration(void)//設(shè)置GPIO端口函數(shù)
{
  GPIO_InitTypeDef GPIO_InitStructure;//GPIO_InitStructure是GPIO_InitTypeDef結(jié)構(gòu)體

  /* Configure PC6 as Output push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;//結(jié)構(gòu)體成員GPIO_Pin賦值
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;//結(jié)構(gòu)體成員GPIO_Speed賦值
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//結(jié)構(gòu)體成員GPIO_Mode賦值
  GPIO_Init(GPIOC, &GPIO_InitStructure);//按照上面賦值的結(jié)構(gòu)體初始化GPIOC端口,
                                                           //就是設(shè)置PC6為速度是50MHz的推挽(推拉)輸出工作模式
        
}


/**************** (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/


實驗4-2 GPIO_Test_2.rar

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

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

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

本版積分規(guī)則

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

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

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