| ??? 04/13/10 09:07 Read: times |
#175014 - My apologies. Responding to: ???'s previous message |
Sorry, I had obviously never used the EEPROM of the 5131. I had just added the conditional code to my library "eeprom.c" without testing on that particular device. I can assure you that the 8252 version works fine.
Yes. The EECON and AUXR are not bit-addressable. So you have to use portable C. Please use the following functions:
unsigned char rdeeprom(unsigned char xdata *ads)
{
unsigned char c;
EECON = 2; /* EEE */
AUXR |= (1<<5); /* MO */
c = *ads; /* needs no cast cos in signature */
AUXR &= ~(1<<5); /* MO = 0 */
EECON = 0; /* brute force */
return c;
}
void wreeprom(unsigned char xdata *ads, unsigned char c)
{
EECON = 2; /* EEE */
*ads = c; /* needs no cast cos in signature */
EECON = 0x52; /* SPECIAL SEQUENCE */
EECON = 0xA2; /* I had written wrong sequence */
while (EECON & 1); /* EEBUSY */
EECON = 0; /* brute force */
}
You can read your EEPROM contents via FLIP. I also noticed that the 5131 seems to manage to read the EEPROM ok without stretching the read-cycle i.e. without setting the MO bit. David. |
| Topic | Author | Date |
| EEPROM Read/Write Issues | 01/01/70 00:00 | |
| if it was an external EEPROM | 01/01/70 00:00 | |
| if it was an external EEPROM | 01/01/70 00:00 | |
| Special sequence. | 01/01/70 00:00 | |
| Thanks, but can you please simplyfy it? | 01/01/70 00:00 | |
| Hope this explains | 01/01/70 00:00 | |
| Managed to fix lockups, but it doesnt read/write | 01/01/70 00:00 | |
| You have to choose your API | 01/01/70 00:00 | |
| Already did all that | 01/01/70 00:00 | |
| char vs int | 01/01/70 00:00 | |
| I gave you a function | 01/01/70 00:00 | |
| Still no luck | 01/01/70 00:00 | |
| unsigned int is not the size of the unsigned int* pointer | 01/01/70 00:00 | |
| Why not use the function I gave you. | 01/01/70 00:00 | |
| I did use you function | 01/01/70 00:00 | |
| My apologies. | 01/01/70 00:00 | |
| Sorry to keep dragging you back here... | 01/01/70 00:00 | |
| FLIP is a pain | 01/01/70 00:00 | |
| We have progress! | 01/01/70 00:00 | |
| Terribly sorry to bump but I really need help | 01/01/70 00:00 | |
| Found the solution! | 01/01/70 00:00 | |
| Study your C textbooks | 01/01/70 00:00 | |
it cant distinguise the sign bit | 01/01/70 00:00 |



