打印

子程序的问题

[复制链接]
1338|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
chen3bing|  楼主 | 2010-10-25 20:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我用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只允许很少级子程序嵌套吗?
我仿真器缺少仿真头,无法仿真。
请高手指教,谢谢!

相关帖子

沙发
chen3bing|  楼主 | 2010-10-25 20:10 | 只看该作者
第二段case1开头处是单独摘出来的,不要误会了。

使用特权

评论回复
板凳
chen3bing|  楼主 | 2010-10-25 20:28 | 只看该作者
找到原因了,定义的时候是comm_pile(),
调用的时候是com_pile(),伟福的编译器居然不报错!

使用特权

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

本版积分规则

439

主题

2539

帖子

2

粉丝