led接PB5和PE5,gpiox_CRL复位值是0x4444 4444,通过代码设置MODE5为01,并没有对CNF5进行操作,理论上CNF5状态应该是01,对应开漏输出状态,但led灯还是亮了,这个是怎么回事,源代码如下:
unsigned int *GPIOE_ODR= (unsigned int *)(0x4001180c);
unsigned int *GPIOB_ODR= (unsigned int *)(0x40010c0c);
void LED1(char flag){
if(flag==0){
*GPIOE_ODR&=~(1<<5);
}
else{
*GPIOE_ODR|=(1<<5);
}
}
void LED0(char flag){
if(flag==0){
*GPIOB_ODR&=~(1<<5);
}
else{
*GPIOB_ODR|=(1<<5);
}
}
void delay(unsigned int x){
unsigned int i;
while(x--){
for(i=500;i>0;i--);
}
}
int main(void){
*(unsigned int *)(0x40021018)|=(1<<3);
*(unsigned int *)(0x40021018)|=(1<<6);
*(unsigned int *)(0x40011800)|=(1<<20);
*(unsigned int *)(0x40010c00)|=(1<<20);
#if 1 //这里置一或者清零都不对实验现象产生影响
*(unsigned int *)(0x40011800)&=~(1<<22);
*(unsigned int *)(0x40010c00)&=~(1<<22);
#endif
while(1){
LED1(0);
LED0(1);
delay(5000);
LED1(1);
LED0(0);
delay(5000);
}
}
void SystemInit(void){
}
|