小弟最近在写一个12864点阵的显示界面,在定时器中断函数中碰到无法正常调用外部函数的问题,程序简要如下:
问题: 在定时器中断函数中,无法正确调用SetX() 和SetY()函数,只能将SetX()和SetY()的内容全部拷贝进去才能实现功能,
在调用DisplayL()时,也不能直接调用SetX()和SetY(),要拷贝其内容进去,
在中断函数中多次调用DisplayL()时,也会出现不正常,要把所有函数的原始内容替代原是函数才能正常执行,请问这是怎么回事?
void P1_C(unsigned char temp1) //Command Write Operation { while(FRP); CSS=0;rd=1; CD=1; P1=temp1; wr=0;wr=1; CSS=1; }
SetX(char x) { P1_C(0x64);delay(100); //Data Write Position X-Address Set P1_C(x);delay(100); }
SetY(char y) { P1_C(0x60);delay(100); //Data Write Position Y-Address Set P1_C(y);delay(100); }
DisplayL(char x,char y,char pcha[29]) { i=0;
//SetX(x);
//SetY(y); P1_C(0x64);delay(100); //Data Write Position X-Address Set P1_C(x);delay(100); P1_C(0x60);delay(100); //Data Write Position Y-Address Set P1_C(y);delay(100); while(i<14) { P1_D(pcha); i++; }
//SetX(x);
//SetY(y);
P1_C(0x64);delay(100); //Data Write Position X-Address Set P1_C(x);delay(100); P1_C(0x60);delay(100); //Data Write Position Y-Address Set P1_C(y+1);delay(100); while(i<28) { P1_D(pcha); i++; } }
void timer0() interrupt 1 using 1 {
TR0 =0; DisplayL(char x,char y,Ee);
DisplayL(char x,char y,Aa);
TR0=1;
}
main() { IT0 = 1; PX0 = 1; IE = 0x83; //启动计时器0和中断0; TMOD = 0x02;//计时器0工作在模式1下; TH0 = 256 - 100; TR0 = 1;
while(1); }
|