I am attempting to use the flash API to erase & write to flash memory from within my program during runtime.
I can succesfully write data to the flash. Here is the code I am using to write a number to the flash:
status = Flash2803x_Program( (Uint16 *) 0x3F4000, &number , 1, &FlashStatus );
if (status != 0) { TxString("Error programming flash!\n\r"); TxNumber(status); }
However, I am not able to erase the flash. Here is the code I am trying to erase with:
status = Flash2803x_Erase( SECTORG,&FlashStatus );
if (status != 0) { TxString("Error erasing flash!\n\r"); TxNumber(status); }
When I call that erase code, it does not ever finish with the Flash2803x_Erase function, and so it does not spit out an erase status. When I call it, the program crashes and it seems memory is overwritten (all of my watch variables become 2989). In order to run the program again, I have to reprogram the chip. CCS reports the following when the chip crashes:
Trouble Reading PC Register:
Error 0x00000004/-1142
Error during: Register,
Processor blocked debug accesses. An operation was attempted while the CPU was in a non-debuggable context. To continue to honor the debug context, press Cancel. To force debug access, press Rude Retry.
Any suggestions?
Thanks,
Brandon
P.S. Below is some of my initialization code:
#define SECTORA (Uint16)0x0001
#define SECTORB (Uint16)0x0002
#define SECTORC (Uint16)0x0004
#define SECTORD (Uint16)0x0008
#define SECTORE (Uint16)0x0010
#define SECTORF (Uint16)0x0020
#define SECTORG (Uint16)0x0040
#define SECTORH (Uint16)0x0080
#define SECTOR_F2803x (SECTORA|SECTORB|SECTORC|SECTORD|SECTORE|SECTORF|SECTORG|SECTORH)
typedef struct {
Uint16 *StartAddr;
Uint16 *EndAddr;
}SECTOR;
#define OTP_START_ADDR 0x3D7800
#define OTP_END_ADDR 0x3D7C00
#define FLASH_END_ADDR 0x3F7FFF
#define FLASH_START_ADDR 0x3E8000
SECTOR Sector[8]= {
(Uint16 *) 0x3E8000,(Uint16 *) 0x3E9FFF, /**< Contains the address of each sector of flash */
(Uint16 *) 0x3EA000,(Uint16 *) 0x3EBFFF,
(Uint16 *) 0x3EC000,(Uint16 *) 0x3EDFFF,
(Uint16 *) 0x3EE000,(Uint16 *) 0x3EFFFF,
(Uint16 *) 0x3F0000,(Uint16 *) 0x3F1FFF,
(Uint16 *) 0x3F2000,(Uint16 *) 0x3F3FFF,
(Uint16 *) 0x3F4000,(Uint16 *) 0x3F4002,
(Uint16 *) 0x3F6000,(Uint16 *) 0x3F7F80,
};