??? 04/12/10 18:31 Modified: 04/12/10 18:47 Read: times |
#175004 - I did use you function Responding to: ???'s previous message |
David Prentice said:
I gave you a pair of functions.
I suggested some test code. You used your functions. You also read from the uninitialised 'user_level' locations. Virgin eeprom reads as 0xFF. If members take the time to both reply and write code for you, it is only a courtesy to read their posts. David. I did read and used your function(Thank you btw, it was your code that fixed the lockups), I just adapted it abit to make it easier for me... eitherway it works the same way. and I did set user_level aswell as user_name: unsigned char xdata user_name[16*userlimit] _at_ 0x00E1; //stores user name.16*userlimit. unsigned char xdata user_level[userlimit] _at_ 0x03B1; //store user level.1*userlimit. I just tried a copy paste of both the codes you wrote void wreeprom(unsigned short ads, unsigned char c) { EECON |= (1<<1); /* EEE */ *((unsigned char xdata *)ads) = c; EECON = 0x54; /* SPECIAL SEQUENCE */ EECON = 0xA4; while (EECON & (1<<0)); /* EEBUSY */ EECON = 0x00; /* brute force */ } and void wreeprom(unsigned short ads, unsigned char c) { #ifdef _i8051 #if defined(_AT89C5131_) EECON |= (1<<1); /* EEE */ *((unsigned char xdata *)ads) = c; EECON = 0x54; /* SPECIAL SEQUENCE */ EECON = 0xA4; while (EECON & (1<<0)); /* EEBUSY */ // EECON &= ~(1<<1); /* EEE */ EECON = 0x00; /* brute force */ #elif defined(_AT89S8252_) WMCON |= (1<<3); /* EEMEN */ WMCON |= (1<<4); /* EEMWE */ *((unsigned char xdata *)ads) = c; while ((WMCON & (1<<1)) == 0) ; /* WDTRST */ WMCON &= ~((1<<3)|(1<<4)); /* EEMEN | EEMWE */ #else #error _i8051 without EEPROM #endif #endif } both are Just with these few alterations: A)EECON is not bit addressable for instead of EEE I wrote EECON=0x02; B)removed the #define AT89S8252 part as it is irrelevant to my MCU C)added the AUXR to read sessions as request by the datasheet: http://www.keil.com/dd/docs/datashts/atmel/at89c5131_ds.pdf in pages 40 and 48. they all give the same result as the function I used (thats based on what you said so no surprise there) |
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 |