Hi, I use the nrf24le1 device in my design. I want to stroe data when power is off, so I write data to the NVM flash. But something is wrong in my design, could you help me ? I have two codes, the first code is described as follows: The flash is earsed firstly, and then I write data to flash, the address is set to 0XFB80, then I read the data in flash, the data which is read is correct. After the first code, I program the second code to the device,the second is described as follows: I read the flash directly, and the data which is read is FF. In my opinion, I have writen the data to the NVM flash sucessfully, the data would not miss when power off. In the second code, I don't write the data to flash, I should read out the data which is writen in first code, but the result is failed. what's wrong with my design.
static xdata uint8_t AES_Key[16] = {0xcc,0x77,0x44,0x18,0x87,0x56,0xb3,0x7d,0x99,0x10,0xc7,0xcc,0x13,0x14,0x15,0x16};
uint8_t data1_buf[16]; void main(void) { uint16_t addr; uint8_t i;
mcu_init();
EA = 1; // Global interrupt enable
hal_uart_init(UART_BAUD_38K4);
addr=0xFB80; // set the flash address
while(1)
{
if (!S2) {
//hal_flash_page_erase(33); // In first code
LED=0;
//hal_flash_bytes_write(addr,AES_Key,16); // in first code
hal_flash_bytes_read(addr,&data1_buf, 16); for(i=0;i<16;i++) { hal_uart_putchar(data1_buf[i]); } LED=1; delay_10ms();
}
}
}