初级会员

- 积分
- 92
- 金钱
- 92
- 注册时间
- 2018-3-18
- 在线时间
- 29 小时
|
20金钱
今天在写电机驱动程序的时候,需要拉低和拉高引脚电平的操作。发现一个问题,如果我把SetBits()函数写进一个while(1)循环我用万用表测不到电压只有0.1-0.2的电压。然后我又试了试GPIO_Write()函数,和上面的现象一样。
如下是配置函数:
void Dianji_Init()
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0|GPIO_Pin_1|GPIO_Pin_2|GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOE,&GPIO_InitStructure);
GPIO_SetBits(GPIOE,GPIO_Pin_0);
}
如下是main.c函数
u8 shunxu1[4]={0x08,0x04,0x02,0x01}; //Õýת D-C-B-A
int x=0x01;
void run()
{
u8 i;
for(i=0;i<4;i++)
{
GPIO_Write(GPIOE,0x01);
delay_ms(5);
}
}
主函数:
int main()
{
Dianji_Init();
delay_ms(30);
while(1)
{
}
}
|
|