//0x4002 1000 - 0x4002 13FF 复位和时钟控制(RCC)
#define RCC_BASE 0x40021000
#define RCC_APB2ENR (RCC_BASE+0x18)
//LED接在GPIOF上,是APB2上的外设,是RCC_APB2ENR寄存器的第7位
//APB20x4001 1c00 GPIO端口F
#define GPIOF_BASE 0x40011c00
#define GPIOF_CHL (0x000+GPIOF_BASE)
#define GPIOF_CHR (0x004+GPIOF_BASE)
#define GPIOF_IDR (0x008+GPIOF_BASE)
#define GPIOF_ODR (0x00c+GPIOF_BASE)
#define GPIOF_BSRR (0x010+GPIOF_BASE)
#define GPIOF_BRR (0x014+GPIOF_BASE)
#define GPIOF_LCKR (0x014+GPIOF_BASE)
void delay(int num)
{
int i,j;
for(i=0;i
for(j=0;j<5000;j++)
;
}
int main(void)
{
*(unsigned int *)RCC_APB2ENR=1<<7;//开gpiof时钟
//设置成开漏输出,频率无所谓,那么cny为0101,mode为0101
*(unsigned int *)GPIOF_CHL=0x55555555;
*((unsigned int *)GPIOF_CHR)=0x55555555;
*((unsigned int *)GPIOF_ODR)=0xffff;
while(1)
{
*((unsigned int *)GPIOF_BSRR)=1<<22;
delay(200);
*((unsigned int *)GPIOF_BSRR)=1<<23;
delay(200);
*((unsigned int *)GPIOF_BSRR)=1<<24;
delay(200);
*((unsigned int *)GPIOF_BSRR)=1<<25;
delay(200);
*((unsigned int *)GPIOF_ODR)=0xffff;
delay(200);
}
}
上一篇:STM32的IAP下载与设置
下一篇:difference for STM32 adc Regular and injected