视频教程点亮LED,PB0口输出低电平时绿灯亮,PB1口蓝灯亮,PB5红灯亮,写的代码想让三种颜色交替亮。
问题1,我写的代码执行起来正常,绿色和蓝色正常,但红色变成了橙色。
问题2,我看霸道开发板原理图LED D4和D5对应的是PF7和PF8,但看参考手册中RCC APB2 外设复位寄存器中没有找到IOPF。
求各位指导一下 代码如下:
#include"stm32f10x.h"
void delay(unsigned int i)
{
while(i--);
}
int main (void)
{
//打开GPIOB端口时钟
*( unsigned int *) 0x40021018 |= ( (1)<<3 );
while(1)
{
*( unsigned int *) 0x40010C00 |= ( (0x0f)<<(4*0) );
//配置IO口PB0为输出
*( unsigned int *) 0x40010C00 |= ( (1)<<(4*0) );
//控制ODR寄存器P0
*( unsigned int *) 0x40010C0C &= ~(1<<0);
delay(900000);
*( unsigned int *) 0x40010C0C |= (1<<0);
//配置IO口PB1为输出
*( unsigned int *) 0x40010C00 |= ( (1)<<(4*1) );
//控制ODR寄存器P1
*( unsigned int *) 0x40010C0C &= ~(1<<1);
delay(900000);
*( unsigned int *) 0x40010C0C |= (1<<1);
//配置IO口PB5为输出
*( unsigned int *) 0x40010C00 |= ( (1)<<(4*5) );
//控制ODR寄存器P5
*( unsigned int *) 0x40010C0C &= ~(1<<5);
delay(900000);
*( unsigned int *) 0x40010C0C |= (1<<5);
}
}
void SystemInit(void)
{
} |