??? 09/24/10 00:39 Read: times |
#178679 - Problem with 89C51ED2 and Dallas DS17887 |
Hi All.
I'm using micro controller AT89C51ED2 interface with DS17887-5 in the extend board (Please see below picture) http://www.mediafire.com/i/?98h7cnqm1g2ksx2 This is: code read/write registry of DS17887. void WrReg(unsigned char add, unsigned char d){ EA=0; P0 = add; ResetWR; ResetRD; P0 = add; D_CS=1; D_ALE=1; D_CS=0; D_ALE=0; P0 = d; SetWR; ResetWR; D_CS=1; D_ALE=1; EA=1; } unsigned char RdReg(unsigned char add){ unsigned char d; EA=0; P0 = add; ResetWR; ResetRD; D_CS=1; D_ALE=1; D_CS=0; D_ALE=0; SetRD; d = P0; ResetRD; D_CS=1; D_ALE=1; EA=1; return d; } void WrExt(unsigned int add, unsigned char d){ WrReg(D_EADDL, (unsigned char)(add&0x00FF)); //Set AddL WrReg(D_EADDH, (unsigned char)((add>>8)&0x00FF)); //Set AddH WrReg(D_EDATA, d); ////Set data } unsigned char RdExt(unsigned int add){ WrReg(D_EADDL, (unsigned char)(add&0x00FF)); //Set AddL WrReg(D_EADDH, (unsigned char)((add>>8)&0x00FF)); //Set AddH return RdReg(D_EDATA); //Read data } void InitRTC(){ WrReg(D_REGA, 0x30); //0011 0000 Bank1 WrReg(D_REGB, 0x02); //0000 0010 BCD, 24h } This is: results write/read bytes in case using 74HC245, error at bytes: 0x20, 0x40, 0x20, 0x80. With 74HCT245 then all is OK. WR RD Wr: 01 01 Wr: 01 01 Wr: 01 01 Wr: 01 01 Wr: 02 02 Wr: 02 02 Wr: 02 02 Wr: 02 02 Wr: 04 00 Wr: 04 00 Wr: 04 00 Wr: 04 00 Wr: 08 00 Wr: 08 00 Wr: 08 00 Wr: 08 00 Wr: 10 10 Wr: 10 10 Wr: 10 10 Wr: 10 10 Wr: 20 00 Wr: 20 00 Wr: 20 00 Wr: 20 00 Wr: 40 40 Wr: 40 40 Wr: 40 40 Wr: 40 40 Wr: 80 00 Wr: 80 00 Wr: 80 00 Wr: 80 00 If I use 74HCT245 then old board and extend board was running OK, but I replace 74HCT245 by 74HC245, then old board was still running OK, Extend Board was running error with DS17887 (Please see my test results when write/read byte 0x01, 0x02,...) I'm using Keil C for programing. I also try to repaire this error by changing timing read/write of software and anything by hardware, but no good results. Please suggest me how to repaire this error. Thanks and waiting your help. Best Regards. |
Topic | Author | Date |
Problem with 89C51ED2 and Dallas DS17887 | 01/01/70 00:00 | |
Schematic of extend board - clearly | 01/01/70 00:00 | |
I may be able to answer, but ... | 01/01/70 00:00 | |
How to post formatted source code | 01/01/70 00:00 | |
Big Tiger | 01/01/70 00:00 |