📄 x24c44.c
字号:
#include <AT89X51.H>
#include "com.h"
#include "X24C44.H"
//-----------------------------------------------
sbit LED_TEST=P3^4;//LED blink test
//*********************************************//
// delay nearly n*0.05s ;;n=20->1s //
//********************************************//
void Delay(unsigned int n)
{ unsigned int i;
for(;n>0;n--)
{ for(i=0;i<10000;) i++; }
}
//------------------LED Blink for Test----------------------------
void Blink(unsigned char t,unsigned char n)
{ unsigned char i;
for(i=0;i<n;i++)
{ LED_TEST=0;Delay(t);LED_TEST=1;Delay(t); }
}
//----------------------------------------------------------------
//-------------------------------------
//#####################################
//-------------------------------------
void main(void)
{
unsigned char i,t;
unsigned int n;
Init_Com();
Blink(3,3);
SendString("Now test the X24C44!!!");CT();
//--------------------
Recall_Ram();
Write_Enable();
//----------------------------
SendString("Now write word to X24C44!!!");CT();
for(i=0;i<5;i++)
{
WriteWord_X24C44(i,i);
Blink(3,1);
SendChar(i+0x30);
}
CT();
SendString("Write over!!!");CT();
//-----------------------------
Store_Ram();
SendString("Now Store_Ram!!!");CT();
//-----------------
Blink(3,3);
//-----------------
Recall_Ram();
SendString("Now Recall_Ram!!!");CT();
SendString("Now read word from X24C44!!!");CT();
for(i=0;i<5;i++)
{
n=ReadWord_X24C44(i);
Blink(3,1);
SendChar(((unsigned char) n)+0x30);
}
CT();
SendString("Read over!!!");CT();
//-----------------
//for(;;);
//-----------------------------
//-------------------------------------------------------------
//----------------------------
Blink(3,3);
Write_Enable();//!!!!!!!!must set it!!!!!
//---------------------------
SendString("Now write char to X24C44!!!");CT();
for(i=0;i<5;i++)
{
WriteChar_X24C44(31-i,4-i);
Blink(3,1);
SendChar(4-i+0x30);
}
CT();
SendString("Write over!!!");CT();
//-----------------------------
//-----------------
Blink(3,3);
//-----------------
SendString("Now read char from X24C44!!!");CT();
for(i=0;i<5;i++)
{
t=ReadChar_X24C44(31-i);
Blink(3,1);
SendChar(t+0x30);
}
CT();
SendString("Read over!!!");CT();
//-----------------------------
Write_Disable();
//--------------------
for(;;);
}
//-------------------------------------
//#####################################
//-------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -