

#include "stm32f10x.h" // Device headerint main(void){RCC->APB2ENR = 0x00000008;GPIOB->CRL = 0x00300000;GPIOB->ODR = 0x00000000;while(1){}}
RCC->APB2ENR = 0x00000008;
GPIOB->CRL = 0x00300000;
GPIOB->ODR = 0x00000000;

对比一下,标准库开发
#include "stm32f10x.h" // Device headerint main(void){// RCC->APB2ENR = 0x00000008;// GPIOB->CRL = 0x00300000;// GPIOB->ODR = 0x00000000;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);//时钟使能GPIO_InitTypeDef GPIO_InitStructure;//GPIO初始化 需要一个结构体GPIO_InitStructureGPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;//GPIO初始化结构体的三个成员 mode Pin ModeGPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;GPIO_Init(GPIOB, &GPIO_InitStructure);//GPIO初始化//GPIO_SetBits(GPIOB,GPIO_Pin_5);//设置为高电平GPIO_ResetBits(GPIOB,GPIO_Pin_5);//设置为低电平while(1){}}
