2004-07-15 06:22 AM
2011-05-17 03:02 AM
Helo,
I have a problem with upsd.I use upsd3233 and in my application i want to write a byte to eeprom(secondary flash sector) and read.My code is at primary flash(0x0000-0x3FFF). I use 0x4000-0x5FFF address area as eeprom. When i programed the upsd and run application data is written to destination and can be read back correctly but if second time wrong data has been written. Here is my code; #define SECTOR_0_BASE_ADDRESS 0x4000 #define BOOT_FLASH_SECTOR_0_XAAA (volatile unsigned char xdata *)0x5AAA #define BOOT_FLASH_SECTOR_0_X555 (volatile unsigned char xdata *) 0x5555 void eeprom_write(uint address,uchar data_byte) { EA = 0; // write data byte *((char xdata *) BOOT_FLASH_SECTOR_0_X555) = 0xAA; *((char xdata *) BOOT_FLASH_SECTOR_0_XAAA) = 0x55; *((char xdata *) BOOT_FLASH_SECTOR_0_X555) = 0xA0; *((char xdata *) SECTOR_0_BASE_ADDRESS) =data_byte; EA = 1; *((char xdata *) BOOT_FLASH_SECTOR_0_X555) = 0xF0;// RESET } What is wrong with my code?2011-05-17 03:02 AM
Please take a look at the 3200 EEPROM Emulation example that is available on the Downloads page:
http://www.stmcu.com/modules.php?name=mcu&file=familiesdocs&fam=80
It works well on the DK3200. I suggest you download it and run it on your DK3200 and then take a look at the code.2011-05-17 03:02 AM
thanks for your fast reply,
I tried eeprom emulation code on my DK3200 board it realy works fine but when i add it to my code keil said ''data space overflow'' so i treid to write mine eeprom routine as you see in previos message.2011-05-17 03:02 AM
Please review the programming flowchart in the data sheet. My first thought is that there is no delay between when you write the byte and then do a reset. In the polling method you have to wait on a bit to change states before the programming cycle is complete. It could be that you are resetting before the programming is complete, so the data doesn't get written properly.
2011-05-17 03:02 AM
milkinis,
While there may be issues with your code writing data correctly, as uPSD suggests, I certainly doubt Keil's compiler would know anything about it. If it's saying something like ''data space overflow'', you probably have your project set to memory model ''small'' in the compiler. Try changing that to large and see if the space overflow goes away. If you like, you could try just specifying individual variables to place in xdata to free up room in the data memory area. Best Regards, Phaze4262011-05-17 03:02 AM
2011-05-17 03:02 AM
I'm afraid the upsd flash is sector erasable but it is byte writable.
To be efficient you would need to implement a linked-list type array. I think this is how the app note mentioned works. Regards sjo2011-05-17 03:02 AM
You mentioned that you changed the ''Options for Target'' such that the Code ROM Size setting is ''Large: 64K program''. Did you also try setting the Memory Model from ''Small: variables in DATA'' to ''Large: variables in XDATA''? I suspect that may be where the ''data space overflow'' error results with the combination of your plus the EEPROM Emulation example. I have seen this issue before and by changing the Memory Model setting, the project compiled fine.