打印
[STM32F1]

按键发送数据之问题一二

[复制链接]
628|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
pi, GPIO, IO, gp, se
当我第二次按下按键后,它会保留第一次的引脚电平这是为什么?比如第一次我发一个1(第一个引脚就会变成高电平),第二次我发一个2(本应该是只有第二引脚变成高电平),但第二次它的引脚是第一个和第二个都是高电平。
        if(key==KEY2_PRES)
        {
    Send_data(p);
        }//主函数中的



void Send_data(u16 *w)
{
        Send_Init();

       
        if((*w&0x01)==0x01)
                GPIO_SetBits(GPIOC,GPIO_Pin_0);
        else
                GPIO_ResetBits(GPIOC,GPIO_Pin_0);
          
        if((*w&0x02)==0x02)
                GPIO_SetBits(GPIOC,GPIO_Pin_1);
        //else
        //GPIO_ResetBits(GPIOC,GPIO_Pin_0);
       
        if((*w&0x04)==0x04)
                GPIO_SetBits(GPIOC,GPIO_Pin_2);
        //else
//        GPIO_ResetBits(GPIOC,GPIO_Pin_0);
       
        if((*w&0x08)==0x08)
                GPIO_SetBits(GPIOC,GPIO_Pin_3);
        //else
        //GPIO_ResetBits(GPIOC,GPIO_Pin_0);
       
       
        if((*w&0x10)==0x10)
                GPIO_SetBits(GPIOC,GPIO_Pin_4);
//        else
        //GPIO_ResetBits(GPIOC,GPIO_Pin_0);
       
        if((*w&0x20)==0x20)
                GPIO_SetBits(GPIOC,GPIO_Pin_5);
        //        else
        //GPIO_ResetBits(GPIOC,GPIO_Pin_0);
               
        if((*w&0x40)==0x40)
                GPIO_SetBits(GPIOB,GPIO_Pin_6);
//        else
        //GPIO_ResetBits(GPIOC,GPIO_Pin_0);       
       
       
        if((*w&0x80)==0x80)
                GPIO_SetBits(GPIOB,GPIO_Pin_7);
        //else
        //GPIO_ResetBits(GPIOC,GPIO_Pin_0);
}
沙发
shisizai| | 2016-9-6 19:30 | 只看该作者
复位都被你注释掉了当然不会灭啊

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

46

主题

247

帖子

4

粉丝