STM32F103C8开发GPIO操作(一)

    xiaoxiao2025-05-25  7

    1、开发环境Keil 5,处理器芯片为stm32f103c8t6。

    2、测试环境为普中科技实验仪。

    3、新建工程>选择芯片类型>选择需要使用的固件库。

    #include "stm32f10x.h" void Delay() { uint16_t i,j; for(i=0;i<1024;i++) for(j=0;j<2048;j++) ; } int main() { GPIO_InitTypeDef GPIO_InitS; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); GPIO_InitS.GPIO_Pin = GPIO_Pin_All; GPIO_InitS.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitS.GPIO_Speed = GPIO_Speed_2MHz; GPIO_Init(GPIOB,&GPIO_InitS); while(1) { GPIO_Write(GPIOB,0xffff); Delay(); GPIO_Write(GPIOB,0x0000); Delay(); } return 0; } 实验现象,将P0与LED排针连接后,LED闪烁。

    转载请注明原文地址: https://ju.6miu.com/read-1299240.html
    最新回复(0)