找回密码
 立即注册
查看: 1274|回复: 10

官方给的例子报错是咋回事呢?STC89-90xx Series MCU IO Demo

[复制链接]
  • 打卡等级:以坛为家I
  • 打卡总天数:235
  • 最近打卡:2025-05-26 23:18:18

83

主题

695

回帖

1315

积分

金牌会员

积分
1315
发表于 2024-4-27 11:48:35 | 显示全部楼层 |阅读模式

//
//由于P0口为开漏模式,所以需要外接10K左右的上拉电阻才可以正常测试
//对于STC90C5xAD/STC9LEC5xAD系列,P4口的地址为 0C0H
//
//P4.5默认为ALE引脚,需要使用ISP下载软件将它编程为P4.5口才可正常测试
//

#include "reg51.h"

sbit P00 = P0^0;
sbit P01 = P0^1;
sbit P02 = P0^2;
sbit P03 = P0^3;
sbit P04 = P0^4;
sbit P05 = P0^5;
sbit P06 = P0^6;
sbit P07 = P0^7;
sbit P10 = P1^0;
sbit P11 = P1^1;
sbit P12 = P1^2;
sbit P13 = P1^3;
sbit P14 = P1^4;
sbit P15 = P1^5;
sbit P16 = P1^6;
sbit P17 = P1^7;
sbit P20 = P2^0;
sbit P21 = P2^1;
sbit P22 = P2^2;
sbit P23 = P2^3;
sbit P24 = P2^4;
sbit P25 = P2^5;
sbit P26 = P2^6;
sbit P27 = P2^7;
sbit P30 = P3^0;
sbit P31 = P3^1;
sbit P32 = P3^2;
sbit P33 = P3^3;
sbit P34 = P3^4;
sbit P35 = P3^5;
sbit P36 = P3^6;
sbit P37 = P3^7;

sfr P4   = 0xC0;
sbit P40 = P4^0;
sbit P41 = P4^1;
sbit P42 = P4^2;
sbit P43 = P4^3;


//sfr P4 = 0xc0;        //STC90C5xAD/STC9LEC5xAD系列

void delay()
{
    int i, j;

    for (i=0; i<1000; i++)
    for (j=0; j<500; j++);
}


void main()
{
    P10 = 0;
    delay();
    P10 = 1;
    P11 = 0;
    delay();
    P11 = 1;
    P12 = 0;
    delay();
    P12 = 1;
    P13 = 0;
    delay();
    P13 = 1;
    P14 = 0;
    delay();
    P14 = 1;
    P15 = 0;
    delay();
    P15 = 1;
    P16 = 0;
    delay();
    P16 = 1;
    P17 = 0;
    delay();
    P17 = 1;

    P30 = 0;
    delay();
    P30 = 1;
    P31 = 0;
    delay();
    P31 = 1;
    P32 = 0;
    delay();
    P32 = 1;
    P33 = 0;
    delay();
    P33 = 1;
    P34 = 0;
    delay();
    P34 = 1;
    P35 = 0;
    delay();
    P35 = 1;
    P36 = 0;
    delay();
    P36 = 1;
    P37 = 0;
    delay();
    P37 = 1;

    P20 = 0;
    delay();
    P20 = 1;
    P21 = 0;
    delay();
    P21 = 1;
    P22 = 0;
    delay();
    P22 = 1;
    P23 = 0;
    delay();
    P23 = 1;
    P24 = 0;
    delay();
    P24 = 1;
    P25 = 0;
    delay();
    P25 = 1;
    P26 = 0;
    delay();
    P26 = 1;
    P27 = 0;
    delay();
    P27 = 1;

    P00 = 0;
    delay();
    P00 = 1;
    P01 = 0;
    delay();
    P01 = 1;
    P02 = 0;
    delay();
    P02 = 1;
    P03 = 0;
    delay();
    P03 = 1;
    P04 = 0;
    delay();
    P04 = 1;
    P05 = 0;
    delay();
    P05 = 1;
    P06 = 0;
    delay();
    P06 = 1;
    P07 = 0;
    delay();
    P07 = 1;

    P40 = 0;
    delay();
    P40 = 1;
    P41 = 0;
    delay();
    P41 = 1;
    P42 = 0;
    delay();
    P42 = 1;
    P43 = 0;
    delay();
    P43 = 1;

    while (1)
    {
        P1 = 0x00;
        delay();
        P1 = 0xff;

        P3 = 0x00;
        delay();
        P3 = 0xff;

        P2 = 0x00;
        delay();
        P2 = 0xff;

        P0 = 0x00;
        delay();
        P0 = 0xff;

        P4 = 0x00;
        delay();
        P4 = 0xff;
    }
}
--------------------------------------------------------------------------
linking...
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  ?C_START
    MODULE:  STARTUP.obj (?C_STARTUP)
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
    SYMBOL:  ?C_START
    MODULE:  STARTUP.obj (?C_STARTUP)
    ADDRESS: 0155H
Program Size: data=9.0 xdata=0 code=343
---------------------------------------------
为什么官方给的例子会报警告呢?

回复

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:447
  • 最近打卡:2025-06-19 15:15:10
已绑定手机

40

主题

2064

回帖

7105

积分

论坛元老

积分
7105
发表于 2024-4-27 11:58:05 | 显示全部楼层
项目里面是不是有“STARTUP.A51”文件?有的话删掉试试。
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:235
  • 最近打卡:2025-05-26 23:18:18

83

主题

695

回帖

1315

积分

金牌会员

积分
1315
发表于 2024-4-27 12:13:48 | 显示全部楼层
乘风*** 发表于 2024-4-27 11:58
项目里面是不是有“STARTUP.A51”文件?有的话删掉试试。

删掉了,也清除缓存了。重新编译还是报
linking...
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  ?C_STARTUP
    MODULE:  rda.obj (RDA)
Program Size: data=8.0 xdata=0 code=328

之前总共两个警告,删除后L2警告没有了,但是L1还是有,是不是和什么选项有关呢?
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:447
  • 最近打卡:2025-06-19 15:15:10
已绑定手机

40

主题

2064

回帖

7105

积分

论坛元老

积分
7105
发表于 2024-4-27 12:17:41 | 显示全部楼层
duro*** 发表于 2024-4-27 12:13
删掉了,也清除缓存了。重新编译还是报
linking...
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL

能否将你的项目打包发出来?
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:235
  • 最近打卡:2025-05-26 23:18:18

83

主题

695

回帖

1315

积分

金牌会员

积分
1315
发表于 2024-4-27 12:25:59 | 显示全部楼层
这个是我的工程,帮我看下,谢谢

my_test.zip

28.02 KB, 下载次数: 75

回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:235
  • 最近打卡:2025-05-26 23:18:18

83

主题

695

回帖

1315

积分

金牌会员

积分
1315
发表于 2024-4-27 12:29:56 | 显示全部楼层
乘风*** 发表于 2024-4-27 12:17
能否将你的项目打包发出来?

compiling my_test.c...
assembling my_test.src...
linking...
*** WARNING L1: UNRESOLVED EXTERNAL SYMBOL
    SYMBOL:  ?C_STARTUP
    MODULE:  my_test.obj (MY_TEST)
Program Size: data=8.0 xdata=0 code=328
creating hex file from "my_test"...
"my_test" - 0 Error(s), 1 Warning(s).
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:235
  • 最近打卡:2025-05-26 23:18:18

83

主题

695

回帖

1315

积分

金牌会员

积分
1315
发表于 2024-4-27 12:31:46 | 显示全部楼层
C51 COMPILER V9.01   MY_TEST                                                               04/27/2024 12:27:20 PAGE 1   


C51 COMPILER V9.01, COMPILATION OF MODULE MY_TEST
NO OBJECT MODULE REQUESTED
COMPILER INVOKED BY: F:\program\KeilC51\C51\BIN\C51.EXE my_test.c BROWSE DEBUG OBJECTEXTEND SRC(.\my_test.SRC)

line level    source

   1          /*------------------------------------------------------------------*/
   2          /* --- STC MCU Limited ---------------------------------------------*/
   3          /* --- STC89-90xx Series MCU IO Demo -------------------------------*/
   4          /* --- Mobile: (86)13922805190 -------------------------------------*/
   5          /* --- Fax: 86-0513-55012956,55012947,55012969 ---------------------*/
   6          /* --- Tel: 86-0513-55012928,55012929,55012966----------------------*/
   7          /* --- Web: www.STCMCU.com -----------------------------------------*/
   8          /* --- Web: www.GXWMCU.com -----------------------------------------*/
   9          /* If you want to use the program or the program referenced in the  */
  10          /* article, please specify in which data and procedures from STC    */
  11          /*------------------------------------------------------------------*/
  12         
  13          //
  14          //由于P0口为开漏模式,所以需要外接10K左右的上拉电阻才可以正常测试
  15          //对于STC90C5xAD/STC9LEC5xAD系列,P4口的地址为 0C0H
  16          //
  17          //P4.5默认为ALE引脚,需要使用ISP下载软件将它编程为P4.5口才可正常测试
  18          //
  19         
  20          #include "reg51.h"
  21         
  22          sbit P00 = P0^0;
  23          sbit P01 = P0^1;
  24          sbit P02 = P0^2;
  25          sbit P03 = P0^3;
  26          sbit P04 = P0^4;
  27          sbit P05 = P0^5;
  28          sbit P06 = P0^6;
  29          sbit P07 = P0^7;
  30          sbit P10 = P1^0;
  31          sbit P11 = P1^1;
  32          sbit P12 = P1^2;
  33          sbit P13 = P1^3;
  34          sbit P14 = P1^4;
  35          sbit P15 = P1^5;
  36          sbit P16 = P1^6;
  37          sbit P17 = P1^7;
  38          sbit P20 = P2^0;
  39          sbit P21 = P2^1;
  40          sbit P22 = P2^2;
  41          sbit P23 = P2^3;
  42          sbit P24 = P2^4;
  43          sbit P25 = P2^5;
  44          sbit P26 = P2^6;
  45          sbit P27 = P2^7;
  46          sbit P30 = P3^0;
  47          sbit P31 = P3^1;
  48          sbit P32 = P3^2;
  49          sbit P33 = P3^3;
  50          sbit P34 = P3^4;
  51          sbit P35 = P3^5;
  52          sbit P36 = P3^6;
  53          sbit P37 = P3^7;
  54         
  55          sfr P4   = 0xC0;
C51 COMPILER V9.01   MY_TEST                                                               04/27/2024 12:27:20 PAGE 2   

  56          sbit P40 = P4^0;
  57          sbit P41 = P4^1;
  58          sbit P42 = P4^2;
  59          sbit P43 = P4^3;
  60         
  61         
  62          //sfr P4 = 0xc0;        //STC90C5xAD/STC9LEC5xAD系列
  63         
  64          void delay()
  65          {
  66   1          int i, j;
  67   1      
  68   1          for (i=0; i<1000; i++)
  69   1          for (j=0; j<500; j++);
  70   1      }
  71         
  72         
  73          void main()
  74          {
  75   1          P10 = 0;
  76   1          delay();
  77   1          P10 = 1;
  78   1          P11 = 0;
  79   1          delay();
  80   1          P11 = 1;
  81   1          P12 = 0;
  82   1          delay();
  83   1          P12 = 1;
  84   1          P13 = 0;
  85   1          delay();
  86   1          P13 = 1;
  87   1          P14 = 0;
  88   1          delay();
  89   1          P14 = 1;
  90   1          P15 = 0;
  91   1          delay();
  92   1          P15 = 1;
  93   1          P16 = 0;
  94   1          delay();
  95   1          P16 = 1;
  96   1          P17 = 0;
  97   1          delay();
  98   1          P17 = 1;
  99   1      
100   1          P30 = 0;
101   1          delay();
102   1          P30 = 1;
103   1          P31 = 0;
104   1          delay();
105   1          P31 = 1;
106   1          P32 = 0;
107   1          delay();
108   1          P32 = 1;
109   1          P33 = 0;
110   1          delay();
111   1          P33 = 1;
112   1          P34 = 0;
113   1          delay();
114   1          P34 = 1;
115   1          P35 = 0;
116   1          delay();
117   1          P35 = 1;
C51 COMPILER V9.01   MY_TEST                                                               04/27/2024 12:27:20 PAGE 3   

118   1          P36 = 0;
119   1          delay();
120   1          P36 = 1;
121   1          P37 = 0;
122   1          delay();
123   1          P37 = 1;
124   1      
125   1          P20 = 0;
126   1          delay();
127   1          P20 = 1;
128   1          P21 = 0;
129   1          delay();
130   1          P21 = 1;
131   1          P22 = 0;
132   1          delay();
133   1          P22 = 1;
134   1          P23 = 0;
135   1          delay();
136   1          P23 = 1;
137   1          P24 = 0;
138   1          delay();
139   1          P24 = 1;
140   1          P25 = 0;
141   1          delay();
142   1          P25 = 1;
143   1          P26 = 0;
144   1          delay();
145   1          P26 = 1;
146   1          P27 = 0;
147   1          delay();
148   1          P27 = 1;
149   1      
150   1          P00 = 0;
151   1          delay();
152   1          P00 = 1;
153   1          P01 = 0;
154   1          delay();
155   1          P01 = 1;
156   1          P02 = 0;
157   1          delay();
158   1          P02 = 1;
159   1          P03 = 0;
160   1          delay();
161   1          P03 = 1;
162   1          P04 = 0;
163   1          delay();
164   1          P04 = 1;
165   1          P05 = 0;
166   1          delay();
167   1          P05 = 1;
168   1          P06 = 0;
169   1          delay();
170   1          P06 = 1;
171   1          P07 = 0;
172   1          delay();
173   1          P07 = 1;
174   1      
175   1          P40 = 0;
176   1          delay();
177   1          P40 = 1;
178   1          P41 = 0;
179   1          delay();
C51 COMPILER V9.01   MY_TEST                                                               04/27/2024 12:27:20 PAGE 4   

180   1          P41 = 1;
181   1          P42 = 0;
182   1          delay();
183   1          P42 = 1;
184   1          P43 = 0;
185   1          delay();
186   1          P43 = 1;
187   1      
188   1          while (1)
189   1          {
190   2              P1 = 0x00;
191   2              delay();
192   2              P1 = 0xff;
193   2      
194   2              P3 = 0x00;
195   2              delay();
196   2              P3 = 0xff;
197   2      
198   2              P2 = 0x00;
199   2              delay();
200   2              P2 = 0xff;
201   2      
202   2              P0 = 0x00;
203   2              delay();
204   2              P0 = 0xff;
205   2      
206   2              P4 = 0x00;
207   2              delay();
208   2              P4 = 0xff;
209   2          }
210   1      }
211         


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    328    ----
   CONSTANT SIZE    =   ----    ----
   XDATA SIZE       =   ----    ----
   PDATA SIZE       =   ----    ----
   DATA SIZE        =   ----    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----    ----
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
-------------------------------------------------------
好奇怪啊,软件界面有警告提示,链接日志里好像又没有。。。。
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:470
  • 最近打卡:2025-06-19 00:01:06
已绑定手机

19

主题

3233

回帖

5297

积分

论坛元老

积分
5297
发表于 2024-4-27 12:37:24 来自手机 | 显示全部楼层
警告没事程序能正常运行就没问题
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家II
  • 打卡总天数:447
  • 最近打卡:2025-06-19 15:15:10
已绑定手机

40

主题

2064

回帖

7105

积分

论坛元老

积分
7105
发表于 2024-4-27 12:38:19 | 显示全部楼层
my_test.c文件右键选择“Options for file...”
截图202404271236375255.jpg
点击选择框,让这两个选项变灰就可以:
截图202404271238162538.jpg
回复 支持 反对

使用道具 举报 送花

  • 打卡等级:以坛为家I
  • 打卡总天数:235
  • 最近打卡:2025-05-26 23:18:18

83

主题

695

回帖

1315

积分

金牌会员

积分
1315
发表于 2024-4-27 12:39:04 | 显示全部楼层
so*** 发表于 2024-4-27 12:37
警告没事程序能正常运行就没问题

最可怕的是潜在问题啊,
回复 支持 反对

使用道具 举报 送花

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|深圳国芯人工智能有限公司 ( 粤ICP备2022108929号-2 )

GMT+8, 2025-6-19 22:19 , Processed in 0.181046 second(s), 101 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表