//外设 peripheral
/*总线基址*/
#define PERIPH_BASE ((unsigned int)0x40000000)
/*APB2基址*/
#define APB2PERIPH_BASE (PERIPH_BASE+0x10000)
/*APB基址*/
#define AHBPERIPH_BASE (PERIPH_BASE+0x20000)
/*GPIO配置地址*/
#define GPIOB_BASE (APB2PERIPH_BASE+0x0C00)
#define RCC_BASE (AHBPERIPH_BASE+0x1000)
/*定义寄存器*/
#define RCC_APB2ENR *(unsigned int*)(RCC_BASE+0x18)
#define GPIOB_CRL *(unsigned int*)(GPIOB_BASE+0X00)
#define GPIOB_ODR *(unsigned int*)(GPIOB_BASE+0X0C)
#define GPIOB_BSRR *(unsigned int*)(GPIOB_BASE+0X10)
#define GPIOB_BRR *(unsigned int*)(GPIOB_BASE+0X14)
#include"stm32f10x.h"
void delay(unsigned int j)
{
while(j--);
}
int main()
{
//设置RCC时钟
RCC_APB2ENR |= ((1)<<3);
//配置GPIO-PB0输出
GPIOB_CRL |= ((1)<<(4*0));
//配置GPIO-PB1输出
GPIOB_CRL |= ((1)<<(4*1));
//配置GPIO-PB5输出
GPIOB_CRL |= ((1)<<(4*5));
while(1)
{
/*GPIOB_ODR &= ~(1<<0);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_ODR |= (1<<0);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_ODR &= ~(1<<1);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_ODR |= (1<<1);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_ODR &= ~(1<<5);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_ODR |= (1<<5);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);*/
//复位+置位寄存器操作
GPIOB_BSRR |= (1<<0);
GPIOB_BSRR |= (1<<1);
GPIOB_BSRR |= (1<<5);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_BSRR |= (1<<16);
GPIOB_BSRR |= (1<<1);
GPIOB_BSRR |= (1<<5);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_BSRR |= (1<<0);
GPIOB_BSRR |= (1<<1);
GPIOB_BSRR |= (1<<5);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_BSRR |= (1<<0);
GPIOB_BSRR |= (1<<17);
GPIOB_BSRR |= (1<<5);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_BSRR |= (1<<0);
GPIOB_BSRR |= (1<<1);
GPIOB_BSRR |= (1<<5);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
GPIOB_BSRR |= (1<<0);
GPIOB_BSRR |= (1<<1);
GPIOB_BSRR |= (1<<21);
delay(0xffff);
delay(0xffff);
delay(0xffff);
delay(0xffff);
}
}
void SystemInit()
{
} |