We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hi, I have come over the problem with LCD. Thankx to all.Any one req. LCD C code can contact me by posting his/her email on this thread. Now i have connected P2.0 to SDA and P2.1 to SCL of AT24C04 EEPROM. Can any one give me his codes for refrance regarding how to READ and WRITE to 24C04. *RU2
101 SCL=0; 102 } 103 104 /**-------------------------------------------------------------------------------- 105 调用方式:uchar I2CReceive(void) ﹫2001/07/0 5 106 函数说明:私有函数,I2C专用 107 ---------------------------------------------------------------------------------*/ 108 Byte I2CReceiveByte(void) 109 { 110 uchar i=8; 111 Byte ddata=0; 112 SDA=1; 113 while (i--) 114 { 115 ddata<<=1; 116 SCL=0;SomeNOP(); 117 SCL=1;SomeNOP(); 118 ddata|=SDA; 119 } 120 SCL=0; 121 return ddata; 122 } 123 124 125 //--------------------------------------------------------------------------- 126 //开始PCF8563T驱动程序 第2 页 文件: PCF8563T.C 2001-11-27, 18:39:20 127 /**-------------------------------------------------------------------------------- 128 调用方式:void GetPCF8563(uchar firsttype,uchar count,uchar *buff) ﹫2001/08/0 7 129 函数说明:读取时钟芯片PCF8563的时间,设置要读的第一个时间类型firsttype,并设置读取 130 的字节数,则会一次把时间读取到buff中。顺序是: 131 0x02:秒/0x03:分/0x04:小时/0x05:日/0x06:星期/0x07:月(世纪)/0x08:年 132 ---------------------------------------------------------------------------------*/ 133 void GetPCF8563(uchar firsttype,uchar count,uchar *buff) 134 { 135 uchar i; 136 I2CStart(); 137 I2CSendByte(0xA2); 138 WaitAck(); 139 I2CSendByte(firsttype); 140 WaitAck(); 141 142 I2CStart(); 143 I2CSendByte(0xA3); 144 WaitAck(); 145 146 for (i=0;i<count;i++) 147 { 148 buff[i]=I2CReceiveByte(); 149 if (i!=count-1) SendAck();//除最后一个字节外,其他都要从MASTER发应答。 150 } 151 152 SendNotAck(); 153 I2CStop(); 154 } 155 156 157 /**-------------------------------------------------------------------------------- 158 调用方式:void SetPCF8563(uchar timetype,uchar value) ﹫2001/08/0 7 159 函数说明:调整时钟。timetype是要改的时间类型,value是新设置的时间值(BCD格式)。 160 0x02:秒/0x03:分/0x04:小时/0x05:日/0x06:星期/0x07:月(世纪)/0x08:年 161 ---------------------------------------------------------------------------------*/ 162 void SetPCF8563(uchar timetype,uchar value) 163 { 164 I2CStart(); 165 I2CSendByte(0xA2); 166 WaitAck(); 167 I2CSendByte(timetype); 168 WaitAck(); 169 I2CSendByte(value); 170 WaitAck(); 171 I2CStop(); 172 } 173 174 /**-------------------------------------------------------------------------------- 175 调用方式:void SetAlarmHour(uchar count) ﹫2001/08/0 7 176 函数说明:设置报警闹钟在一天的第count点报警。例如:count=23,则在晚上11点报警。 177 ---------------------------------------------------------------------------------*/ 178 void SetAlarm(uchar alarmtype,uchar count) 179 { 180 SetPCF8563(0x01,0x02); 181 SetPCF8563(alarmtype,count); 182 } 183 184 /**-------------------------------------------------------------------------------- 185 调用方式:void CleanAlarm(void) ﹫2001/08/0 7 186 函数说明:清除所有报警设置。 187 ---------------------------------------------------------------------------------*/ 188 void CleanAlarm(void) 189 { 第3 页 文件: PCF8563T.C 2001-11-27, 18:39:20 190 SetPCF8563(0x01,0x00); 191 SetPCF8563(0x09,0x80); 192 SetPCF8563(0x0A,0x80); 193 SetPCF8563(0x0B,0x80); 194 SetPCF8563(0x0C,0x80); 195 // SetPCF8563(0x0D,0x00); 196 // SetPCF8563(0x0E,0x03); 197 } 198 199 200 /*--------------------------------------------------------------------------------
201 调用方式:uchar read1380(uchar command ) 202 函数说明:read1380()返回当前时间, command指要返回的时间类型。 203 秒:81H 分钟:83H 小时:85H 日期:87H 星期:89H 星期几:8BH 年:8D H 204 ---------------------------------------------------------------------------------*/ 205 uchar read1380 (uchar command) 206 { 207 uchar time; 208 GetPCF8563(command,1,&time); 209 return time; 210 } 211 212 /*-------------------------------------------------------------------------------- 213 调用方式:void write1380(uchar command ,uchar time ) 214 函数说明:write1380()往HT1380写命令和数据,command是命令字, time是后写入的数据 215 ---------------------------------------------------------------------------------*/ 216 void write1380(uchar command ,uchar time) 217 { 218 SetPCF8563(command,time); 219 } 220 221 222 /*-------------------------------------------------------------------------------- 223 调用方式:void time_display(uchar x0,uchar y0 ) 224 函数说明:time_display()在指定的x0,y0坐标,以00:00:00格式显示当前时间。 225 ---------------------------------------------------------------------------------*/ 226 //uchar time[]="00:11:11"; 227 228 void time_display(uchar x0,uchar y0,bit type) //液晶时间显示 229 { 230 uchar time[]="00:00:00"; 231 uchar con[3]; 232 uchar time_type; 233 GetPCF8563(0x02,3,con); 234 235 time[0]=(con[2]>>4)+'0'; 236 time[1]=(con[2]&0x0f)+'0'; 237 time[3]=(con[1]>>4)+'0'; 238 time[4]=(con[1]&0x0f)+'0'; 239 time[6]=(con[0]>>4)+'0'; 240 time[7]=(con[0]&0x0f)+'0'; 241 242 time[8]=0; 243 if(type==1) 244 { 245 time_type=0xff; 246 } 247 else 248 { 249 time_type=0; 250 } 251 dipchar0(x0,y0,F57,1,time_type,time); 252 } 第4 页 文件: PCF8563T.C 2001-11-27, 18:39:20
Thankx haha, I will surely let u know if i do any modification or optimization or addition to u r refrance code. please give me u r email so that i can share some of my codes with u. rutu
hi rutu and all:) u're welcome.and the code is no mine:),but you can use it anywhere~ my e-mail:feichen201@hotmail.com