STM32
直播中

陈萍

7年用户 196经验值
私信 关注
[问答]

外部中断,按这个键,别的按键中断为什么会有反应?

我按加减的键,key的值会随机的发生改变,时钟调时老是不行,是哪里问题,各位大哥指点啊
void Systick_Handler(void){    num++;if(num==10){num=0;miao++;if(miao>=60){fen++;miao=0;if(fen>=60){   shi++;   fen=0;   if(shi>=24)   {     week++;  ri++;  shi=0;  if(week>=8)  {   week=1;  }  GUI_Rectangle(96,126,128,174,0xffff,1);          dis_32_48(96,126,week,(u16 *)picture);  if(ri>=32)  {   ri=1; month++; if(month>=13) {  month=1; year++; if(year>=10000) { year=0; } year1=year/1000;                 year2=(year%1000)/100;                 year3=(year%100)/10;                    year4=(year%10);                 GUI_Rectangle(96,10,192,58,0xffff,1);                 dis_32_48(96,10,year1,(u16 *)picture);                     dis_32_48(128,10,year2,(u16 *)picture);                 dis_32_48(160,10,year3,(u16 *)picture);                 dis_32_48(192,10,year4,(u16 *)picture); } month1=month/10;                month2=month%10;                GUI_Rectangle(64,68,128,116,0xffff,1);                dis_32_48(64,68,month1,(u16 *)picture);                dis_32_48(96,68,month2,(u16 *)picture);  }              
  ri1=ri/10;          ri2=ri%10;          GUI_Rectangle(200,68,264,116,0xffff,1);          dis_32_48(200,68,ri1,(u16 *)picture);          dis_32_48(232,68,ri2,(u16 *)picture);   }   shi1=shi/10;       shi2=shi%10;       GUI_Rectangle(0,184,64,232,0xffff,1);       dis_32_48(0,184,shi1,(u16 *)picture);       dis_32_48(32,184,shi2,(u16 *)picture);}fen1=fen/10;fen2=fen%10;GUI_Rectangle(96,184,162,232,0xffff,1);dis_32_48(96,184,fen1,(u16 *)picture);dis_32_48(128,184,fen2,(u16 *)picture);}miao1=miao/10;miao2=miao%10;GUI_Rectangle(192,184,256,232,0xffff,1);dis_32_48(192,184,miao1,(u16 *)picture);dis_32_48(224,184,miao2,(u16 *)picture);  }//num1=num/100; //   num2=num/10;//num3=num%10;//GUI_Rectangle(144,34,192,58,0x0000,1);//zifu_16_24(144,34,num1,0x07e0); //   zifu_16_24(160,34,num2,0x07e0);//zifu_16_24(176,34,num3,0x07e0);
}
void EXTI0_IRQHandler(void)//WA键,就是右键,keynum3{        Delay(0x2fff);
  if(EXTI_GetITStatus(EXTI_Line0) != RESET)       {    switch(key)     {
  case 1:miao++;if(miao>=60)miao=0;                miao1=miao/10;                      miao2=miao%10;                    GUI_Rectangle(192,184,256,232,0xffff,1);                     dis_32_48(192,184,miao1,(u16 *)picture);                    dis_32_48(224,184,miao2,(u16 *)picture);break;  case 2:fen++;if(fen>=60)fen=0;               fen1=fen/10;                   fen2=fen%10;                   GUI_Rectangle(96,184,162,232,0xffff,1);                   dis_32_48(96,184,fen1,(u16 *)picture);                    dis_32_48(130,184,fen2,(u16 *)picture);             break;  case 3:shi++;if(shi>=24)shi=0;  shi1=shi/10;                    shi2=shi%10;                    GUI_Rectangle(0,184,64,232,0xffff,1);                    dis_32_48(0,184,shi1,(u16 *)picture);                    dis_32_48(32,184,shi2,(u16 *)picture);                break;  case 4:ri++;if(ri>=32)ri=1;    ri1=ri/10;                  ri2=ri%10;                  GUI_Rectangle(200,68,264,116,0xffff,1);                  dis_32_48(200,68,ri1,(u16 *)picture);                  dis_32_48(232,68,ri2,(u16 *)picture);              break;  case 5:week++;if(week>=8)week=1;    GUI_Rectangle(96,126,128,174,0xffff,1);                  dis_32_48(96,126,week,(u16 *)picture);              break;  case 6:month++;if(month>=13)month=1;    month1=month/10;                month2=month%10;                GUI_Rectangle(64,68,128,116,0xffff,1);                dis_32_48(64,68,month1,(u16 *)picture);                dis_32_48(96,68,month2,(u16 *)picture);              break;  case 7:year++;if(year>=10000)year=0;   year1=year/1000;                 year2=(year%1000)/100;                 year3=(year%100)/10;                    year4=(year%10);                 GUI_Rectangle(96,10,192,58,0xffff,1);                 dis_32_48(96,10,year1,(u16 *)picture);                     dis_32_48(128,10,year2,(u16 *)picture);                 dis_32_48(160,10,year3,(u16 *)picture);                 dis_32_48(192,10,year4,(u16 *)picture);             break;  }
  EXTI_ClearFlag(EXTI_Line0);  }   }void EXTI9_5_IRQHandler(void)//user1键,下键,keynum4{     Delay(0x2ffff);    if(EXTI_GetITStatus(EXTI_Line8) != RESET)              {                 key++;             if(key>=8)              {              key=0;              }           EXTI_ClearFlag(EXTI_Line8);    } }void EXTI15_10_IRQHandler(void)  //TAM键,左键,keynum1{        Delay(0x2ffff);       if(EXTI_GetITStatus(EXTI_Line13) != RESET)            {       switch(key)       {
  case 1:miao--;if(miao<0)miao=59;              miao1=miao/10;                          miao2=miao%10;                    GUI_Rectangle(192,184,256,232,0xffff,1);                    dis_32_48(192,184,miao1,(u16 *)picture);                   dis_32_48(224,184,miao2,(u16 *)picture);break;  case 2:fen--;if(fen<0)fen=59;              fen1=fen/10;                   fen2=fen%10;                   GUI_Rectangle(96,184,160,232,0xffff,1);                   dis_32_48(96,184,fen1,(u16 *)picture);                    dis_32_48(130,184,fen2,(u16 *)picture);             break;  case 3:shi--;if(shi<0)shi=23;              shi1=shi/10;                    shi2=shi%10;                    GUI_Rectangle(0,184,64,232,0xffff,1);                    dis_32_48(0,184,shi1,(u16 *)picture);                    dis_32_48(32,184,shi2,(u16 *)picture);                break;  case 4:ri--;if(ri<1)ri=31;             ri1=ri/10;                  ri2=ri%10;                  GUI_Rectangle(200,68,264,116,0xffff,1);          dis_32_48(200,68,ri1,(u16 *)picture);          dis_32_48(232,68,ri2,(u16 *)picture);              break;  case 5:week--;if(week<1)week=7;             GUI_Rectangle(96,126,128,174,0xffff,1);                  dis_32_48(96,126,week,(u16 *)picture);              break;  case 6:month--;if(month<1)month=12;                month1=month/10;                month2=month%10;                GUI_Rectangle(64,68,128,116,0xffff,1);                dis_32_48(64,68,month1,(u16 *)picture);                dis_32_48(96,68,month2,(u16 *)picture);              break;  case 7:year--;if(year<0)year=9999;                year1=year/1000;                 year2=(year%1000)/100;                 year3=(year%100)/10;                    year4=(year%10);                 GUI_Rectangle(96,10,192,58,0xffff,1);                 dis_32_48(96,10,year1,(u16 *)picture);                     dis_32_48(128,10,year2,(u16 *)picture);                 dis_32_48(160,10,year3,(u16 *)picture);                 dis_32_48(192,10,year4,(u16 *)picture);             break;  }
  EXTI_ClearFlag(EXTI_Line13);  } }

回帖(2)

赵文隽

2020-7-20 16:03:43
仿真跟踪一下看看。
举报

张飞雄

2020-7-20 16:20:15
几百行代码? 你觉得谁有时间帮你一行行看?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分