论坛风格切换切换到宽版
  • 4499阅读
  • 13回复

是不是要杯具了? [复制链接]

上一主题 下一主题
离线Apple
 
发帖
759
只看楼主 倒序阅读 0楼 发表于: 2010-03-12
花一个礼拜作焊了一个2051的实验板,焊好了觉得程序好像要超过2k。 :eek:

准备做一个控制车载6cd换碟机的东西,看i/o口2051肯定是够了
1,8个用来连1602
2,2个用来uart
3,1个红外口
4,4个按键
15个口线正好,1602还能富余出一个备用。

但是,cdc串口协议,显示,按键,红外能放到2k里面吗?
我用keil c的,没什么经验,c还行,有经验。

我是在做一个8051的实验板?还是努力把程序做小到2k?
这些功能2k有可能吗?
离线BG4UVR
发帖
11266
只看该作者 1楼 发表于: 2010-03-12
先把程序写了编译一下就知道了啊
离线BG4RFF
发帖
1581
只看该作者 2楼 发表于: 2010-03-12
4051或者stc的
离线bv2ac
发帖
14169
只看该作者 3楼 发表于: 2010-03-12
megawin mg87fe6051 可有 6k flash, 256 byte ram, 支持 isp iap icp....
离线Apple
发帖
759
只看该作者 4楼 发表于: 2010-03-12
还是杯具阿,买了好多片2051了。

问个初级问题:
我用keil的例子,hello,编译了一遍,出来的hex文件有3.07k,能烧进去,这个hex不是直接的rom映射?

网上看了一个例子,用2051直接驱动vga的俄罗斯方块,感觉那个程序不小啊,也能做到2k。
==============分割=======================
build target 'simulator'
compiling hello.c...
linking...
program size: data=30.1 xdata=0 code=1095
creating hex file from "hello"...
"hello" - 0 error(s), 0 warning(s).
==============分割完======================
程序大小是多少?
data=30.1? 为啥有小数点?
code=1095 !!! 就一个hello就1k多吗?
离线BG4RFF
发帖
1581
只看该作者 5楼 发表于: 2010-03-12
hex的大小不能代表代码的长短,bin直接和rom对应,用hextobin转换后再看,还有你上机试一下就知道了
离线BG4RFF
发帖
1581
只看该作者 6楼 发表于: 2010-03-12
实在不行就优化呗
离线Apple
发帖
759
只看该作者 7楼 发表于: 2010-03-12
晕死!
有编译了一个1602测试的例子
==============分割=======================
build target 'target 1'
compiling z1602.c...
linking...
program size: data=17.0 xdata=3 code=367
creating hex file from "l1602"...
"l1602" - 0 error(s), 0 warning(s).
==============分割完======================
结果变小了,才367,而且出了xdata=3,我没有外部存储的。晕ing

变小可能是因为没有printf,printf估计超级大。
离线Apple
发帖
759
只看该作者 8楼 发表于: 2010-03-12
hello.c(1602的180行,不贴了)
/*------------------------------------------------------------------------------
hello.c

copyright 1995-2005 keil software, inc.
------------------------------------------------------------------------------*/

#include <reg52.h>           /* special function register declarations   */
                      /* for the intended 8051 derivative       */

#include <stdio.h>           /* prototype declarations for i/o functions */


#ifdef monitor51                 /* debugging with monitor-51 needs   */
char code reserve [3] _at_ 0x23;       /* space for serial interrupt if   */
#endif                       /* stop exection with serial intr.   */
                          /* is enabled                 */


/*------------------------------------------------
the main c function. program execution starts
here after stack initialization.
------------------------------------------------*/
void main (void) {

/*------------------------------------------------
setup the serial port for 1200 baud at 16mhz.
------------------------------------------------*/
#ifndef monitor51
  scon = 0x50;                 /* scon: mode 1, 8-bit uart, enable rcvr     */
  tmod |= 0x20;           /* tmod: timer 1, mode 2, 8-bit reload     */
  //th1   = 221;           /* th1: reload value for 1200 baud @ 16mhz   */
     th1 = 0xfd;   /*th1: reload value for 9600 baud @ 11.0592mhz */
  tr1   = 1;             /* tr1: timer 1 run                 */
  ti   = 1;             /* ti:   set ti to send first char of uart   */
#endif

/*------------------------------------------------
note that an embedded program never exits (because
there is no operating system to return to). it
must loop and execute forever.
------------------------------------------------*/
while (1) {
  p1 ^= 0x01;                 /* toggle p1.0 each time we print */
  printf ("hello world\n");   /* print "hello world" */
}
}
离线BG4RFF
发帖
1581
只看该作者 9楼 发表于: 2010-03-12
code就是代码的大小
离线小比尔/5
发帖
2582
只看该作者 10楼 发表于: 2010-03-12
没有关系,可以把1602里没有用的功能裁剪掉
这些功能占空间的哦,2k应该还是有希望的
.1是因为有位变量
离线vr2ro
发帖
5983
只看该作者 11楼 发表于: 2010-03-12
做来干什么用? 玩玩还凑合。
离线wycx
发帖
1497
只看该作者 12楼 发表于: 2010-03-13
用户被禁言,该主题自动屏蔽!
离线代洪波
发帖
4809
只看该作者 13楼 发表于: 2010-03-21
直接用烧写软件打开看看就知道多大了,另外自己写c程序的压缩空间是很大的.很书写方法有很大关系,程序结构可以优化的地方也太多了,最近写了个接近10k的51程序,很有体会.希望交流