尛白 发表于 2025-2-19 11:41:52

8g1k08芯片的外部中断0可以触发,但是1不行是为什么

#include "STC8G.h"
#include "intrins.h"
#define uintunsigned int
#define uchar unsigned char
#define uintunsigned int
#define uchar unsigned char
#define beep P23
#define dula P26
#define wela P27
uint    num , c;

uchar code table[]={
                                                                0x3f,0x06,0x5b,0x4f,
                                                                0x66,0x6d,0x7d,0x07,
                                                                0x7f,0x6f,0x77,0x7c,
                                                                0x39,0x5e,0x79,0x71};
                void DelayMs(uint c);
                void Display(uint shu);
                                                                              
void main(void)
{   
                P0M0 = 0xff; P0M1 = 0x00;
    P1M0 = 0xff; P1M1 = 0x00;
    P2M0 = 0xff; P2M1 = 0x00;
    P3M0 = 0x50; P3M1 = 0x50;
    P4M0 = 0xff; P4M1 = 0x00;
    P5M0 = 0x10; P5M1 = 0x10;
    P6M0 = 0xff; P6M1 = 0x00;
    P7M0 = 0xff; P7M1 = 0x00;

                IE1= 0;   
    IE0= 0;
    EX1 = 1;    //INT1 Enable
    EX0 = 1;    //INT0 Enable
                ET1      =1;
    IT0 = 1;         
//IT0 = 0;      
//         IT1 = 0;         
                IT1 =1;         
                EA=1;
      
               
      P37=0;
      P36=0;
      P35=0;
      num==0;
      
      while(1)
      {
                Display(num);
      
      }

}



void INt0_int (void)       interrupt 0      
{
                  if(P32==0)
                        {
                        Display(num);
                        num++;
                        P5M0=0x20;
                        while(!P32);
                        Display(num);
                        P5M0=0x00;
                        }
               
}


void INt1_int (void)      interrupt2   
{
      if(P54==0)
                        {
                        num--;
                        P5M0=0x20;
                              while(!P54);
                        Display(num);
                              P5M0=0x00;
                        }
}

void Display(uint shu)
{
                P37=0;
                P1=table;//ÏÔʾ0
                DelayMs(5);
                P37=1;
      
                P36=0;
                P1=table;//ÏÔʾ0
                DelayMs(5);
                P36=1;
      
                P35=0;
                P1=table;//ÏÔʾ0
                DelayMs(5);
                P35=1;
}



void DelayMs(uint c)
      {
      uint a,b;
      for(a=c;a>0;a--)
                for(b=115;b>0;b--);
}


      

晓飛飛 发表于 2025-2-19 11:48:35

建议做个最简单的专项测试例程,独立测试一下功能,

尛白 发表于 2025-2-19 11:53:42

晓飛飛 发表于 2025-2-19 11:48
建议做个最简单的专项测试例程,独立测试一下功能,

好,我试试

AI芯 发表于 2025-2-19 13:10:04

可以参考ISP软件里的例程


https://www.stcaimcu.com/data/download/Tools/AIapp-ISP-v6.95F.zip

尛白 发表于 2025-2-24 11:06:11

已解决,谢谢了
页: [1]
查看完整版本: 8g1k08芯片的外部中断0可以触发,但是1不行是为什么