⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 copy.c

📁 EEPROM局部抄写软件,可以任意设置地址,抄写一段数据,数据由母片提供.
💻 C
📖 第 1 页 / 共 3 页
字号:
   return(retc);
}

void feedAckI2c( bit a )
{
	if ( a == 0) SDA9 = 0;
	else SDA9 = 1;
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	_Nop();
    SCL = 1;
	_Nop();
	_Nop();
	_Nop();
    	_Nop();
    	_Nop();
	_Nop();
	SCL = 0;
	_Nop();
	_Nop();
	_Nop();
}

bit fed_RS16K ( uchar sla, uchar suba, uchar *s, uchar no )
{
	uchar i;
	feedStartI2c ();
	feedSend_byte (sla);
    	if( ack == 0 ) return (0);
	feedSend_byte (suba);
		if (ack == 0 ) return (0);
        feedStartI2c();
	feedSend_byte(sla + 1);
		if ( ack == 0) return ( 0 );
	for(i =0;i< no -1; i++)
		{
		*s = feedRcv_byte();
		feedAckI2c(0);
		s++;
		}
	*s = feedRcv_byte();
	feedAckI2c(1);
	feedStopI2c();
	return(1);
}



bit fed_RS32K ( uchar sla, uint suba, uchar *s, uchar no )
{
	uchar i;
	feedStartI2c ();
 	feedSend_byte (sla);
    	if( ack == 0 ) return (0);
	feedSend_byte (suba / 256);       // the high byte address
		if (ack == 0 ) return (0);
        feedSend_byte (suba % 256);       // the low byte address
		if (ack == 0 ) return (0);
	feedStartI2c();
	feedSend_byte(sla + 1);
		if ( ack == 0) return ( 0 );
	for(i =0;i< no -1; i++)
		{
		*s = feedRcv_byte();
		feedAckI2c(0);
		s++;
		}
	*s = feedRcv_byte();
	feedAckI2c(1);
	feedStopI2c();
	return(1);
}
////////////////////////////////////////////
  bit feedSendStr16K( uchar sla, uchar suba, uchar *s, uchar no )
{
        uchar i;
        feedStartI2c();
        feedSend_byte(sla);
        if(ack == 0)return (0);
        feedSend_byte(suba);
           if(ack == 0)return (0);
        for( i = 0; i < no ;i ++)
        {
                feedSend_byte(*s);
                if(ack == 0)return (0);
                s++;
         }
         feedStopI2c();
         return (1);
}
bit feedSendStr32K( uchar sla, uint suba, uchar *s, uchar no )
{
        uchar i;
        feedStartI2c ();
    	feedSend_byte (sla);
        if(ack == 0)return (0);
        feedSend_byte(suba / 256);  // the high byte address
        if(ack == 0)return (0);
        feedSend_byte(suba % 256);   // the low byte address
        if(ack == 0)return (0);
        for( i = 0; i < no-1 ;i ++)
        {
                   feedSend_byte(*s);
                if(ack == 0)return (0);
                s++;
         }
		  feedSend_byte(*s);
         feedStopI2c();

         return (1);
}
/*bit JUBU_location_check()
{


           uchar BitCnt;
           uchar c = 0xa0;
           jubuStartI2c();

	for( BitCnt = 0; BitCnt < 8; BitCnt ++ )
	{
		if((c << BitCnt) & 0x80) SDA1 = 1;

		else

        	SDA1 =0;

		_Nop();
		_Nop();
		SCL = 1;
		_Nop();
		_Nop();
		_Nop();
		_Nop();
		_Nop();
       	_Nop();
        	_Nop();
		SCL = 0;
              _Nop();
		_Nop();
		_Nop();
	}
	_Nop();
	_Nop();
	_Nop();
   	SDA1 =1;

	_Nop();
	_Nop();
	_Nop();
	_Nop();
	SCL = 1;
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	if(SDA1==0)    CONTR = SDA1;
    else 
		
		ALM=1;
	SCL = 0;
	_Nop();
	_Nop();
	_Nop();

        jubuStopI2c();
        return (1);

}*/
//////////////////////////////////////
bit JUBU0_location_check(void)
{


           uchar BitCnt;
           uchar c = 0xa0;
           jubuStartI2c();

	for( BitCnt = 0; BitCnt < 8; BitCnt ++ )
	{
		if((c << BitCnt) & 0x80) SDA1 = 1;

		else

        	SDA1 =0;

		_Nop();
		_Nop();
		SCL = 1;
		_Nop();
		_Nop();
		_Nop();
		_Nop();
		_Nop();
       	_Nop();
        	_Nop();
		SCL = 0;
              _Nop();
		_Nop();
		_Nop();
	}
	_Nop();
	_Nop();
	_Nop();
   	SDA1 =1;

	_Nop();
	_Nop();
	_Nop();
	_Nop();
	SCL = 1;
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	if(SDA1==0)    LED2 = SDA1;
    else 
	ALM=1;
	SCL = 0;
	_Nop();
	_Nop();
	_Nop();

        jubuStopI2c();
        return (1);

}
////////////////////////////////////////
bit feed_jubu_location_check()
{


           uchar BitCnt;
           uchar c = 0xa0;
           feedStartI2c();

	for( BitCnt = 0; BitCnt < 8; BitCnt ++ )
	{
		if((c << BitCnt) & 0x80) SDA9 = 1;

		else

        	SDA9 =0;

		_Nop();
		_Nop();
		SCL = 1;
		_Nop();
		_Nop();
		_Nop();
		_Nop();
		_Nop();
       	_Nop();
        	_Nop();
		SCL = 0;
              _Nop();
		_Nop();
		_Nop();
	}
	_Nop();
	_Nop();
	_Nop();
   	SDA9 =1;

	_Nop();
	_Nop();
	_Nop();
	_Nop();
	SCL = 1;
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	_Nop();
	if(SDA9==0)	LED2 = SDA9;
    else 
		{while(1){LED2=0;delay(500);LED2=1;delay(500);}}
	SCL = 0;
	_Nop();
	_Nop();
	_Nop();

        feedStopI2c();
        return (1);

}
///////////////////////////////////////////
bit feed_space_check()
{
	uchar BitCnt;		//+zcq 20040518

//-zcq 20040518           uchar BitCnt, test[6];
           uchar c = 0xa2;
           feedStartI2c();

	for( BitCnt = 0; BitCnt < 8; BitCnt ++ )
	{
		if((c << BitCnt) & 0x80) SDA9 = 1;
		else        SDA9 = 0;

 		_Nop();
		_Nop();
		SCL = 1;
   	    	_Nop();
		_Nop();
		_Nop();
 		_Nop();
		_Nop();
        	_Nop();
		SCL = 0;
              _Nop();
 		_Nop();
	}
	_Nop();
 	_Nop();
   	SDA9 = 1;

	_Nop();
 	_Nop();
       _Nop();
	SCL = 1;
       _Nop();
	_Nop();
 	_Nop();
	_Nop();
	_Nop();
       _Nop();
	if( SDA9 == 0 )
        {
              feed_space = 'm';
              SCL = 0;
	      	_Nop();
             	_Nop();
 		_Nop();

              feedStopI2c();    //
              return (1);
        }
        else
        {
		SCL = 0;
		_Nop();
        	_Nop();
 		_Nop();

        	feedStopI2c();    //

        	feed_space = 'o';

        	return (1);
        }

}
///////////////////////////////
 void TIMER0(void) interrupt 1 using 2
  { 
 
	TH0=0x87;
	TL0=0x58;
	P0=SEG[MODE1];
	P3=0xfe;  //11111110
	delay2(1);
	P0=SEG[LENG_LO];
	P3=0xfd; //11111101
	delay2(1);
    P0=SEG[LENG_HI]; 
    P3=0xfb;//11111011
    delay2(2);
    P0=SEG[LOL];   
 	P3=0XF7;//11110111
	delay2(2);
    P0=SEG[LOH];   
 	P3=0xef; //11101111
	delay2(1);
	P0=SEG[HIL];
    P3=0Xdf; //11011111
    delay2(1);
    P0=SEG[HIH];
    P3=0xbf;//10111111

  //delay2(1);

  }              

////////////////////////////////////////
void init(void)
{
	P1=0XFF;
	P3=0XFF;
	IE=0X00;
	ALM=0;
   // ALM0=0;
	ok=0;
	TMOD=0X00;
	CONTR1=1;
	feed_jubu_location_check();
   delay(10);
	CONTR=0;
	delay(100);
	ET0=1;
	TR0=0;
	EA=1;
}
 uint count11,count22,count33;
//////////////////////////////////////////////////
///        主程序
/////////////////////////////////////////
void  pal_copy(uchar hi_add,uchar lo_add,	uint pal_count11,uchar leng)
{ uchar i, j,sub_add;
  uint count;
   uchar pal_buffer;
   uchar pal_buffer0;
	
	if( feed_space == 'm')
	 {   
	    for( count=(((uint)hi_add)*256+(uint)lo_add)  ; count< (pal_count11+(uint)leng); count++) 
	     { j=count/256;
	       j=j<<1;
	 	sub_add=count%256;
	 	
                     				
		fed_RS16K(0xa0+j ,0x00+sub_add, &pal_buffer, 1 );
		 delay(12);
		jubuSendStr16K(0xa0+j ,0x00+sub_add, &pal_buffer, 1 );
	 	  delay(12);
	 	 jubu_RS16K(0xa0+j ,0x00+sub_add, &pal_buffer0, 1 );
		 //delay(12);
	 	   if(pal_buffer==pal_buffer0){LED2=LED2^1;continue;}
	 	      for(i=5;i>0;i--)
                  {SPEAKE=0;LED2=0;delay(100);SPEAKE=1;LED2=1;delay(200);SPEAKE=0;LED2=0;delay(100);SPEAKE=1;LED2=1;ALM=0;}
               return;
	      }
	  }
	 if(feed_space=='o')
	{
		 for(count=(((uint)hi_add)*256+(uint)lo_add); count< (pal_count11+(uint)leng); count++) 
		{
			 fed_RS32K ( 0xa0, 0x0000+count, &pal_buffer, 1 );
			 delay(12);
			 jubuSendStr32K( 0xa0, 0x0000+count, &pal_buffer, 1 );
		   delay(12);
		   jubu_RS32K ( 0xa0, 0x0000+count, &pal_buffer0, 1 );
		   //delay(12);
	 	   if(pal_buffer==pal_buffer0){LED2=LED2^1;continue;}
	 	    for(i=5;i>0;i--)
          {SPEAKE=0;LED2=0;delay(100);SPEAKE=1;LED2=1;delay(200);SPEAKE=0;LED2=0;delay(100);SPEAKE=1;LED2=1;ALM=0;}
             return;
		}
	}

 }
 ///////////////////////////////////////////////
void  pal_copy0(uchar hi_add,uchar lo_add,	uint pal_count11,uchar leng)
{ uchar i, j,sub_add;
  uint count;
   uchar pal_buffer;
   uchar pal_buffer0;
	
	if( feed_space == 'm')
	 {   
	    for( count=(((uint)hi_add)*256+(uint)lo_add)  ; count< (pal_count11+(uint)leng); count++) 
	     { j=count/256;
	       j=j<<1;
	 	sub_add=count%256;            				
	     jubu_RS16K(0xa0+j ,0x00+sub_add, &pal_buffer0, 1 );
		 //delay(12);
	     feedSendStr16K(0xa0+j ,0x00+sub_add, &pal_buffer0,1 );
	 	  delay(12);
	 	 fed_RS16K(0xa0+j ,0x00+sub_add, &pal_buffer, 1 );
		 //delay(12);
	 	   if(pal_buffer==pal_buffer0){LED2=LED2^1;continue;}
	 	      for(i=5;i>0;i--)
                  {SPEAKE=0;LED2=0;delay(100);SPEAKE=1;LED2=1;delay(200);SPEAKE=0;LED2=0;delay(100);SPEAKE=1;LED2=1;ALM=0;}
               return;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -