// PROGRAM : 5-18.c 2011.0529
// FUNCTION : HT93LC16 Read/Write Control By Steven
#include "HT66F50.h"
#include "5-18.H"
const char Str1[]={"1.WRITE 2.WRITE ALL"};
const char Str2[]={"3.ERASE 4.ERAL 5.RD"};
const char Str3[]={"WR: PRESS 0~9, ENTER"};
const char Str4[]={"I/P 2-DIG HEX DATA"};
const char Str5[]={"I/P 2-DIG ADDRESS:"};
const char Str6[]={"ERASING ALL ......"};
const char Str7[]={"SELECT 1)ADDRS 2)ALL"};
const char Str8[]={"I/P ADDRS(2-DIG HEX)"};
const char Str9[]={"ADDRS=>"};
const char StrA[]={"ERASING 1 LOCATION.."};
const char StrB[]={"EEPROM WRITTING....."};
const char StrC[]={" DATA="},StrD[]={"DATA=>"};
void LCMInit(void);
unsigned short LCMWrite(bit,unsigned short);
void DisplayBuffer4(unsigned short, unsigned short*);
void PAUSE(unsigned short);
unsigned short GetKey(void);
unsigned short GetKeys(unsigned short*);
unsigned short ScanKey(void);
unsigned short Get2Keys(void);
unsigned short READ(unsigned short);
void EWEN(void);
void WRITE(unsigned short,unsigned short);
void WRAL(unsigned short);
void EWDS(void);
void ERASE(unsigned short);
void ERAL(void);
void Init93LC46(void);
void WCMD_93LC46(unsigned short,unsigned short);
void WDAT_93LC46(unsigned short);
unsigned short Read_93LC46(void);
void Wait_93LC46(void);
void main()
{ unsigned short i,Key,Key2,Buffer[16];
unsigned short Address;
_acerl=0x00; _cp0c=0x08;_cp1c=0x08; //Disable AD/CP0/CP1
Init93LC46(); LCMInit(); //93LC46 & LCM Initialization
while(1)
{ LCMWrite(0,0x80); i=0; //Set Line1
while(Str1[i]!=0) LCMWrite(1,Str1[i++]); //Display Str1
LCMWrite(0,0xC0); i=0; //Set Line2
while(Str2[i]!=0) LCMWrite(1,Str2[i++]); //Display Str2
do Key=GetKey(); while(Key==0 || Key>6); //Wait Function Select
LCMWrite(0,1); i=0; //Clear LCM Display
switch (Key) //WRITE
{ case 1: //Weite Function Select
do
{ LCMWrite(0,1); i=0; //Clear LCM
while(Str5[i]!=0) //Display Str5
LCMWrite(1,Str5[i++]);
Address=Get2Keys(); //Read User I/P Address(HEX)
} while(Address>=128); //Make Sure Address Range
PAUSE(50);
LCMWrite(0,1); i=0;
while(Str3[i]!=0) //Display Str3
LCMWrite(1,Str3[i++]);
LCMWrite(0,0xC0); //Line2/POS0
Buffer[0]=GetKeys(Buffer+1); //Read User I/P Data
if((Buffer[0]==0)||(Buffer[0]+Address>128))
break; //Braek if No Input or Over-count
LCMWrite(0,1); i=0; //Clear LCM Display
while(StrB[i]!=0) //Display StrB
LCMWrite(1,StrB[i++]);
EWEN(); //Write Enable
for(i=0;i<Buffer[0];i++) //Write Keys
{ WRITE(Address++,Buffer[i+1]);
Wait_93LC46();
}
EWDS(); //Write Disable
break;
case 2: //Write All Function
while(Str4[i]!=0) //Display Str4
LCMWrite(1,Str4[i++]);
LCMWrite(0,0xC0); i=0; //Line2/POS0
while(StrD[i]!=0) //Display StrD
LCMWrite(1,StrD[i++]);
Buffer[0]=Get2Keys(); //Read User I/P Data(HEX)
LCMWrite(0,0x80); i=0; //Set Line 1
while(StrB[i]!=0) //Display StrB
LCMWrite(1,StrB[i++]);
EWEN(); //Write Enable
WRAL(Buffer[0]); Wait_93LC46();
EWDS(); //Write Disable
break;
case 3: //Erase Function
do
{ LCMWrite(0,1); i=0; //Clear LCM
while(Str5[i]!=0) //Display Str5
LCMWrite(1,Str5[i++]);
Address=Get2Keys(); //Read User I/P Address(HEX)
} while(Address>=128); //Make Sure Address Range
LCMWrite(0,0xC0); i=0; //Set Line2/P0
while(StrA[i]!=0) //Display StrA
LCMWrite(1,StrA[i++]);
EWEN(); //Write Enable
ERASE(Address); Wait_93LC46();
EWDS(); //Write Disable
PAUSE(50); break;
case 4: //Erase All Function
while(Str6[i]!=0) //Display Str6
LCMWrite(1,Str6[i++]);
EWEN(); //Write Enable
ERAL(); Wait_93LC46();
EWDS(); //Write Disable
break;
case 5: //Read Function
while(Str7[i]!=0)
LCMWrite(1,Str7[i++]); //Display Str7
do Key2=GetKey(); //Wait Until 1 or 2 is Selected
while((Key2!=1)&&(Key2!=2));
if(Key2==1) //Read Specific Address
{ LCMWrite(0,1); i=0; //CLear LCM
while(Str8[i]!=0)
LCMWrite(1,Str8[i++]); //Display Str8
do
{ LCMWrite(0,0xC0); i=0; //Line 2
while(Str9[i]!=0)
LCMWrite(1,Str9[i++]); //Display Str9
Address=Get2Keys(); //Read User I/P Address(HEX)
} while(Address>=128); //Make Sure Address Range
i=0;
while(StrC[i]!=0)
LCMWrite(1,StrC[i++]); //Display StrC
Buffer[0]=READ(Address);
Buffer[1]=(Buffer[0]>>4); //Get Hi-Nibble
Buffer[1]+=(Buffer[1]>9) ? 0x37 : 0x30; //Convert to ASCII
LCMWrite(1,Buffer[1]); //Display Data(Hi-Nibble)
Buffer[0]&=0x0F; //Get Lo-Nibble
Buffer[0]+=(Buffer[0]>9) ? 0x37 : 0x30; //Convert to ASCII
LCMWrite(1,Buffer[0]); //Display Data(Lo-Nibble)
GetKey(); break; //Wait Key Pressed
}
else //Read All Data
{ Address=0;
while(1)
{ Buffer[15]=Address;
for(i=0;i<8;i++) //Read 8-Byte Data
Buffer[i]=READ(Address++);
LCMWrite(0,1); //LCM Clear
DisplayBuffer4(Buffer[15],Buffer); //Display 4-Byte Data
LCMWrite(0,0xC0);Buffer[15]+=4; //Set Line 2
DisplayBuffer4(Buffer[15],Buffer+4);//Display 4-Byte Data
if(Address>=128) Address=0; //Boundary Check
do i=GetKey(); while(i<13); //Wait Function Select
if(i==15) break; //"Enter" Pressed
if(i==14) //"B.WD" Pressed
{ if(Address==8) //00~7F Boundary Check
{ Address=0x78;}
else if(Address==0)
{ Address=0x70;}
else Address-=16;
}
}
}
break;
}
if(Key!=0 && Key<=5) PAUSE(50); //Delay 0.5S for Function Select
}
}
unsigned short Get2Keys(void)
{ unsigned short temp,temp1,temp2;
temp=GetKey();
temp1=((temp>9) ? temp+0x37 : temp+0x30); //Convert to ASCII
LCMWrite(1,temp1); _swap(&temp);
temp2=GetKey();
temp1=((temp2>9) ? temp2+0x37 : temp2+0x30); //Convert to ASCII
LCMWrite(1,temp1);
return (temp|=temp2);
}
unsigned short READ(unsigned short Address) //READ Command
{ unsigned short Data;
WCMD_93LC46(OPCODE_READ,Address);
Data=Read_93LC46();
MICORW_CS=0; //Set CS=0
return Data;
}
void EWEN(void) //EWEN Command
{ WCMD_93LC46(OPCODE_,0b01100000); //Set EWEN Opcode
MICORW_CS=0; //Set CS=0
}
void WRITE(unsigned short Address,unsigned short Data)//WRITE Command
{ WCMD_93LC46(OPCODE_WRITE,Address);
WDAT_93LC46(Data);
MICORW_CS=0; //Set CS=0
}
void WRAL(unsigned short Data) //WRAL Command
{ WCMD_93LC46(OPCODE_,0b00100000); //Set WRAL Opcode
WDAT_93LC46(Data);
MICORW_CS=0; //Set CS=0
}
void EWDS(void) //EWDS Command
{ WCMD_93LC46(OPCODE_,0b00000000); //Set EWDS Opcode
MICORW_CS=0; //Set CS=0
}
void ERASE(unsigned short Address) //ERASE Command
{ WCMD_93LC46(OPCODE_ERASE,Address);
MICORW_CS=0; //Set CS=0
}
void ERAL(void) //ERAL Command
{ WCMD_93LC46(OPCODE_,0b01000000); //Set ERAL Opcode
MICORW_CS=0; //Set CS=0
}
void Init93LC46(void)
{ MICORW_CS=0; MICORW_SK=0; MICORW_DI=0; //Clear CS/SK/DI Pin
MICORW_CSC=0; MICORW_SKC=0; MICORW_DIC=0; //Config CS/SK/DI Pin
MICORW_DOC=1; //Config DO Pin
}
void WCMD_93LC46(unsigned short OpCode,unsigned short Address)
{ unsigned short
没有合适的资源?快使用搜索试试~ 我知道了~
合泰单片机HT66F50软件DEMO实验例程源码30个合集.zip
共572个文件
tsk:34个
opt:34个
bin:34个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 2 下载量 105 浏览量
2022-03-20
12:11:17
上传
评论
收藏 1.21MB ZIP 举报
温馨提示
合泰单片机HT66F50软件DEMO实验例程源码30个合集,可供学习设计参考。
资源推荐
资源详情
资源评论
收起资源包目录
合泰单片机HT66F50软件DEMO实验例程源码30个合集.zip (572个子文件)
5-17.ASM 58KB
5-18.ASM 57KB
5-16.ASM 38KB
5-12.ASM 25KB
5-13.ASM 24KB
5-5.ASM 22KB
4-17.ASM 21KB
5-9.ASM 18KB
5-15.ASM 16KB
5-14.ASM 12KB
5-2.ASM 11KB
5-4.ASM 11KB
5-8.ASM 11KB
5-7.ASM 11KB
4-20.ASM 11KB
5-3.ASM 9KB
4-16.ASM 9KB
5-6.ASM 9KB
4-18.ASM 8KB
4-12.ASM 8KB
4-10.ASM 7KB
4-13.ASM 7KB
4-7.ASM 7KB
4-8.ASM 6KB
4-19.ASM 6KB
4-14.ASM 6KB
4-6.ASM 6KB
4-15.ASM 5KB
4-9.ASM 5KB
4-4.ASM 5KB
4-2.ASM 5KB
4-5.ASM 5KB
4-11.ASM 5KB
4-3.ASM 4KB
5-4.bin 16KB
4-17.bin 16KB
4-8.bin 16KB
4-6.bin 16KB
4-5.bin 16KB
4-12.bin 16KB
4-7.bin 16KB
5-6.bin 16KB
4-2.bin 16KB
4-18.bin 16KB
5-5.bin 16KB
4-16.bin 16KB
4-9.bin 16KB
4-4.bin 16KB
4-15.bin 16KB
5-17.bin 16KB
5-18.bin 16KB
5-7.bin 16KB
5-15.bin 16KB
4-20.bin 16KB
5-8.bin 16KB
4-11.bin 16KB
4-19.bin 16KB
5-14.bin 16KB
5-9.bin 16KB
4-3.bin 16KB
5-12.bin 16KB
5-13.bin 16KB
5-3.bin 16KB
5-2.bin 16KB
4-13.bin 16KB
4-10.bin 16KB
5-16.bin 16KB
4-14.bin 16KB
5-18.c 12KB
5-17.c 12KB
5-16.c 8KB
5-12.c 5KB
4-17.c 5KB
5-13.c 5KB
5-9.c 4KB
5-15.c 3KB
5-5.c 3KB
5-7.c 3KB
4-20.c 3KB
5-8.c 2KB
5-14.c 2KB
4-16.c 2KB
5-2.c 2KB
4-18.c 2KB
5-6.c 2KB
5-4.c 2KB
5-3.c 2KB
4-10.c 2KB
4-12.c 1KB
4-13.c 1KB
4-7.c 1KB
4-15.c 1KB
4-8.c 1KB
4-19.c 1KB
4-14.c 980B
4-9.c 976B
4-11.c 809B
4-5.c 802B
4-4.c 745B
4-6.c 685B
共 572 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
- m0_705353372023-04-10资源内容详细全面,与描述一致,对我很有用,有一定的使用价值。
- dianxin20232023-07-12资源很赞,希望多一些这类资源。
SKCQTGZX
- 粉丝: 88
- 资源: 5818
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功