Помогите, почему то из флеш памяти не читает, как хотелось:
Flash memory after being erased: FF FF FF FF FF FF FF FF
Flash memory after being written: 01 02 03 04 05 06 07 08
на самом деле:
Flash memory after being erased: FF FF FF FF FF FF FF FF
Flash memory after being written: FF FF FF FF FF FF FF FF
в чем глюк?
Код:
#include <18F452.h>
#fuses HS,NOWDT,PUT,BROWNOUT,NOLVP, NOPROTECT, CPB
#use delay(clock=10000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#define ROM_ADDR 0x4000
//====================================
void main(void)
{
int8 i;
int8 write_data[8] = {1,2,3,4,5,6,7,8};
int8 read_data[8] = {0,0,0,0,0,0,0,0};
printf("Flash write size = %u\n\r", getenv("FLASH_WRITE_SIZE"));
printf("\n\r");
// Erase flash memory.
erase_program_eeprom(ROM_ADDR);
// Read flash memory.
read_program_memory(ROM_ADDR, read_data, sizeof(read_data));
// Display it, to show it's erased.
printf("Flash memory after being erased: ");
for(i = 0; i < sizeof(read_data); i++)
printf("%X ", read_data[i]);
printf("\n\r");
printf("\n\r");
// Now write 8 bytes.
write_program_memory(ROM_ADDR, write_data, sizeof(write_data));
// Read them back.
read_program_memory(ROM_ADDR, read_data, sizeof(read_data));
// Display data read from Flash memory.
printf("Flash memory after being written: ");
for(i = 0; i < sizeof(read_data); i++)
printf("%X ", read_data[i]);
printf("\n\r");
printf("\n\r");
while(1);
}