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

📄 rs232.#3

📁 里面包括RS232和IIC对24LC256的读写代码 CYGNAL IDE打开项目
💻 #3
字号:
/***************************************************************************
  RS232 communication 
  Write by dududu(Email:xx_xiong@163.com)
  Data:2005-3
  add I2C communication  2005-4-4
***************************************************************************/

#define UART  0
 
#include "c8051F330.h"
#include "rs232.h"
void delay(int);
extern char rece,count_UART,count_UART1,Rec_OK,Tran_OK;
extern char Tran_Flag;
extern unsigned char xdata sRecComBuf[8];
extern char *pointer;
main(void)
{
	unsigned int address;
	unsigned char temp_char[11];                  // temporary variable
	PCA0MD &= ~0x40;           // Disable Watchdog timer
	Port_IO_Init();
	Oscillator_Init();
	UART_Init();
	I2C_Init();
	Timer3_Init();
	EA  = 1 ;        //Enable all interrupt
	#if UART
	while(1)
	{
	 //SBUF0=0x4c;
		pointer=sRecComBuf;
	 	count_UART=0;
		count_UART1=0;
		Tran_Flag=0;
		Rec_OK=0;
		Tran_OK=0;
		while(Rec_OK!=0x23)
	 		;
		pointer=sRecComBuf;
		while(Tran_OK!=0x45)
		{
			Tran_Flag=1;
			SBUF0=*pointer++;
			count_UART1++;
			delay(100);
			while(Tran_Flag)
			;
		}
	}
	#endif
	while(1)
	{
		 address = 0x0325;
		 EEPROM_ByteWrite(address, 0x3e);// Read the value at location 0x0325 in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0x4e);// Read the value at location 0x0326 in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0x5e);// Read the value at location 0x0327 in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0x6e);// Read the value at location 0x0328 in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0x7e);// Read the value at location 0x0329 in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0x8e);// Read the value at location 0x032a in the EEPROM
//   		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0x9e);// Read the value at location 0x032b in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0xae);// Read the value at location 0x032c in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0xbe);// Read the value at location 0x032d in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0xce);// Read the value at location 0x032e in the EEPROM
 //  		 delay(1000);
		 address++;
		 EEPROM_ByteWrite(address, 0xde);// Read the value at location 0x032f in the EEPROM
//   		 delay(1000);
		 address++;
		 temp_char[0] = EEPROM_ByteRead(0x0325);
//		 delay(1000);
		 temp_char[1] = EEPROM_ByteRead(0x0326);
//		 delay(1000);
		 temp_char[2] = EEPROM_ByteRead(0x0327);
//		 delay(1000);
		 temp_char[3] = EEPROM_ByteRead(0x0328);
//		 delay(1000);
		 temp_char[4] = EEPROM_ByteRead(0x0329);
//		 delay(1000);
		 temp_char[5] = EEPROM_ByteRead(0x032a);
//		 delay(1000);
		 temp_char[6] = EEPROM_ByteRead(0x032b);
//		 delay(1000);
		 temp_char[7] = EEPROM_ByteRead(0x032c);
//		 delay(1000);
		 temp_char[8] = EEPROM_ByteRead(0x032d);
//		 delay(1000);
		 temp_char[9] = EEPROM_ByteRead(0x032e);
//		 delay(1000);
		 temp_char[10] = EEPROM_ByteRead(0x032f);
		 delay(1000);
   }	 	
}



void delay (int i)
{
	int m;
	for(m=0;m<i;m++)
	;
}

⌨️ 快捷键说明

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