#include "stm32f10x.h" // Device header
int main(void)
{
//寄存器点灯 操作手册→给对应位高低电平点灯 会影响寄存器其他位
//RCC->APB2ENR=0x00000010;//IO端口C时钟开启
//GPIOC->CRH=0x00300000;//设置pc13模式 CNF13[1:0]:00 MODE13[1:0]:11
//GPIOC->ODR=0x00000000;//对应位为低电平 pc13灯亮
//GPIOC->ODR=0x00002000;//对应位为高电平 灯灭
//库函数点灯 不影响寄存器其他位
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC,ENABLE);//时钟开启
GPIO_InitTypeDef GPIO_InitStructure;//定义结构体 配置端口模式中一参数
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_13;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOC,&GPIO_InitStructure);//配置端口模式
GPIO_ResetBits(GPIOC,GPIO_Pin_13);//设置pc13低电平
GPIO_SetBits(GPIOC,GPIO_Pin_13);//设置pc13高电平
while(1)//死循环
{
}
}
运行效果
pc13低电平

pc13高电平

890

被折叠的 条评论
为什么被折叠?



