您现在所在的是:

单片机论坛

回帖:0个,阅读:1241 [上一页] [1] [下一页]
* 帖子主题:

单片机c程序01

931
zhaosiyun
文章数:8
年度积分:50
历史总积分:931
注册时间:2008/9/10
发站内信
发表于:2008/9/11 22:30:00
#0楼
16进制10进制互换程序
unsigned char d[10];    //用于显示的10位显示缓存
//========================================================
   //16进制to10进制输出子程序:显示数据,起始位,结束位,有无小数点
//========================================================
void output(unsigned long dd,unsigned char s,unsigned char e,unsigned char dip) {
   unsigned long div;
   unsigned char tm[8],i,j;
   div=10000000;
   for (i=0;i10进制互换程序
unsigned char d[10];    //用于显示的10位显示缓存
//========================================================
   //16进制to10进制输出子程序:显示数据,起始位,结束位,有无小数点
//========================================================
void output(unsigned long dd,unsigned char s,unsigned char e,unsigned char dip) {
   unsigned long div;
   unsigned char tm[8],i,j;
   div=10000000;
   for (i=0;i
#include
#include
#define e 8
#define p 9
#define l 10
sbit led=p3^2;
sbit p27=p2^7;
sbit p26=p2^6;
sbit p36=p3^6;
sbit p37=p3^7;
sbit rst=p3^3;
sbit ale=p3^5;
sbit vpp=p3^4;
bit b_break;
unsigned int adds;
//    13.8ms
void int_t0(void) interrupt 1 {
   th0=-100;
   b_break=1;
}
void wait(unsigned char w) {
   unsigned int t=w*184;
   b_break=0;
   tl0=-t%256-1;th0=-t/256;
   while (b_break==0) {}
}
void nop(void) {
   _nop_();_nop_();_nop_();_nop_();
   _nop_();_nop_();_nop_();_nop_();
   _nop_();_nop_();_nop_();_nop_();
   _nop_();_nop_();_nop_();_nop_();
   _nop_();_nop_();_nop_();_nop_();
}
unsigned char command(void) {
   th0=-100;b_break=0;
   while (ri==0) {if (b_break==1) return(0);}
   ri=0;
   return(sbuf);
}
void earsure(unsigned char cpu) {
   switch (cpu) {
   case 1:        //89c51
   case 2:rst=p26=1;p27=p36=p37=0;nop();vpp=1;nop();
       ale=0;wait(110);ale=1;nop();
       break;
   case 3:
   case 4:break;
   case 5:
   case 6:break;
   }
}
void program(unsigned char cpu) {
   unsigned int bdata adds=0;
   unsigned char d;
   switch (cpu) {
   case 1:    //89c51
   case 2:
       p36=p37=1;rst=1;
       while (1) {
           th0=-100;b_break=0;
           while (ri==0) {if (b_break==1) return;}
           ri=0;
           d=sbuf;
           //address
           p0=adds%256;
           p2=adds/256;
           p27=1;
           //data
           p1=d;
           nop();    //48clcl
           //vpp
           vpp=1;
           nop();    //48clcl
           //ale
           ale=0;
           wait(1);//100us
           ale=1;
           nop();    //10us
           vpp=0;
           nop();    //48clcl
           p27=0;
           nop();    //48clcl
           p1=0xff;
           th0=-100;b_break=0;
           while (d!=p1) {if (b_break==1) return;}    //data polling
           sbuf=d;
           adds++;
       }
       break;
   case 3:
   case 4:
   case 5:
   case 6:break;
   }
}
----------------------------------------------
此篇文章从博客转发
原文地址: Http://blog.gkong.com/more.asp?id=61988&Name=zhaosiyun

关于我们 | 联系我们 | 广告服务 | 本站动态 | 友情链接 | 法律声明 | 非法和不良信息举报

工控网客服热线:0755-86369299
版权所有 工控网 Copyright©2024 Gkong.com, All Rights Reserved

31.2002