我用P89C58X2做一款电池巡检仪,写了一部分程序,
发现一个问题。
在程序中,有一部分代码如下:
case 1:
{
clear();
disp_yw(0xb1,0x10,0x08,0x43); //
disp_yw(0xb1,0x11,0x00,0x4f); //
disp_yw(0xb1,0x11,0x08,0x4d); //
disp_yw(0xb1,0x12,0x00,0x4d); //
disp_yw(0xb1,0x12,0x08,0x00); //
disp_yw(0xb1,0x13,0x00,0x53); //
disp_yw(0xb1,0x13,0x08,0x45); //
disp_yw(0xb1,0x14,0x00,0x54); //
disp_yw(0xb1,0x14,0x08,0x54); //
disp_yw(0xb1,0x15,0x00,0x49); //
disp_yw(0xb1,0x15,0x08,0x4e); //
disp_yw(0xb1,0x16,0x00,0x47); //
disp_yw(0xb3,0x10,0x08,0x50); //p
disp_yw(0xb3,0x11,0x00,0x49); //i
disp_yw(0xb3,0x11,0x08,0x4c); //l
disp_yw(0xb3,0x12,0x00,0x45); //e
disp_yw(0xb3,0x12,0x08,0x00); //
disp_yw(0xb3,0x13,0x00,0x53); // s
disp_yw(0xb3,0x13,0x08,0x45); // e
disp_yw(0xb3,0x14,0x00,0x54); // t
disp_yw(0xb3,0x14,0x08,0x54); // t
disp_yw(0xb3,0x15,0x00,0x49); // i
disp_yw(0xb3,0x15,0x08,0x4e); // n
disp_yw(0xb3,0x16,0x00,0x47); // g
disp_yw(0xb5,0x10,0x00,0x3e); //o
disp_yw(0xb5,0x10,0x08,0x3d); //n
disp_yw(0xb5,0x11,0x00,0x1a); //e
disp_yw(0xb5,0x11,0x08,0x60); //
disp_yw(0xb5,0x12,0x00,0x0d); //c
disp_yw(0xb5,0x12,0x08,0x1a); // e
disp_yw(0xb5,0x13,0x00,0x3b); // l
disp_yw(0xb5,0x13,0x08,0x3b); // l
disp_yw(0xb5,0x14,0x00,0x60); //
disp_yw(0xb5,0x14,0x08,0x5e); // s
disp_yw(0xb5,0x15,0x00,0x1a); // e
disp_yw(0xb5,0x15,0x08,0x5f); // t
disp_yw(0xb5,0x16,0x00,0x5f); // t
disp_yw(0xb5,0x16,0x08,0x1e); // i
disp_yw(0xb5,0x17,0x00,0x3d); // n
disp_yw(0xb5,0x17,0x08,0x1c); // g
disp_yw(0xb7,0x12,0x00,0x52); // r
disp_yw(0xb7,0x12,0x08,0x45); // e
disp_yw(0xb7,0x13,0x00,0x54); // t
disp_yw(0xb7,0x13,0x08,0x55); // u
disp_yw(0xb7,0x14,0x00,0x52); // r
disp_yw(0xb7,0x14,0x08,0x4e); // n
//com_pile();
position=2;
break;
}
这样程序运行正常。
我把其中一部分和另一段程序相同的部分做成子程序,调用。
程序老复位。不知何故?
代码如下:
void comm_pile(void)
{clear();
disp_yw(0xb1,0x10,0x08,0x43); //
disp_yw(0xb1,0x11,0x00,0x4f); //
disp_yw(0xb1,0x11,0x08,0x4d); //
disp_yw(0xb1,0x12,0x00,0x4d); //
disp_yw(0xb1,0x12,0x08,0x00); //
disp_yw(0xb1,0x13,0x00,0x53); //
disp_yw(0xb1,0x13,0x08,0x45); //
disp_yw(0xb1,0x14,0x00,0x54); //
disp_yw(0xb1,0x14,0x08,0x54); //
disp_yw(0xb1,0x15,0x00,0x49); //
disp_yw(0xb1,0x15,0x08,0x4e); //
disp_yw(0xb1,0x16,0x00,0x47); //
disp_yw(0xb3,0x10,0x08,0x50); //p
disp_yw(0xb3,0x11,0x00,0x49); //i
disp_yw(0xb3,0x11,0x08,0x4c); //l
disp_yw(0xb3,0x12,0x00,0x45); //e
disp_yw(0xb3,0x12,0x08,0x00); //
disp_yw(0xb3,0x13,0x00,0x53); // s
disp_yw(0xb3,0x13,0x08,0x45); // e
disp_yw(0xb3,0x14,0x00,0x54); // t
disp_yw(0xb3,0x14,0x08,0x54); // t
disp_yw(0xb3,0x15,0x00,0x49); // i
disp_yw(0xb3,0x15,0x08,0x4e); // n
disp_yw(0xb3,0x16,0x00,0x47); // g
}
case 1:
{ com_pile();
disp_yw(0xb5,0x10,0x00,0x3e); //o
disp_yw(0xb5,0x10,0x08,0x3d); //n
disp_yw(0xb5,0x11,0x00,0x1a); //e
disp_yw(0xb5,0x11,0x08,0x60); //
disp_yw(0xb5,0x12,0x00,0x0d); //c
disp_yw(0xb5,0x12,0x08,0x1a); // e
disp_yw(0xb5,0x13,0x00,0x3b); // l
disp_yw(0xb5,0x13,0x08,0x3b); // l
disp_yw(0xb5,0x14,0x00,0x60); //
disp_yw(0xb5,0x14,0x08,0x5e); // s
disp_yw(0xb5,0x15,0x00,0x1a); // e
disp_yw(0xb5,0x15,0x08,0x5f); // t
disp_yw(0xb5,0x16,0x00,0x5f); // t
disp_yw(0xb5,0x16,0x08,0x1e); // i
disp_yw(0xb5,0x17,0x00,0x3d); // n
disp_yw(0xb5,0x17,0x08,0x1c); // g
disp_yw(0xb7,0x12,0x00,0x52); // r
disp_yw(0xb7,0x12,0x08,0x45); // e
disp_yw(0xb7,0x13,0x00,0x54); // t
disp_yw(0xb7,0x13,0x08,0x55); // u
disp_yw(0xb7,0x14,0x00,0x52); // r
disp_yw(0xb7,0x14,0x08,0x4e); // n
position=2;
break;
}
我想不通,按说子程序嵌套也不多,怎么就复位了呢?
难道P89C58X2只允许很少级子程序嵌套吗?
我仿真器缺少仿真头,无法仿真。
请高手指教,谢谢! |