hi, i build a test project to test IAP(in system program) function of nrf24le1. the project just did follow things:
1. setup uart;
2. erase page 30
3. write data "0xaa,0x55" to memory code space 0x3c00(page 30);
4. read out data from address 0x3c00, and print it through uart;
some other setting as follows:
1. NUPP=FPCR=0XFF: no page is protecded;
2. when read/write/erase memory code space, pmw is set, otherwise pmw is unset;
3. the project only occupy about 1k memory code space, so 0x03c00 should be able to read/write;
the result is unsatisfied. function involves memory code space will cause the project crash.
pls help. my code as follows:
void Init()
while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M){} // wait until xosc ready
// 32K clock init
hal_clklf_set_source(HAL_CLKLF_RCOSC32K);
while(!(hal_clklf_ready())){} // wait until rc32k is ready
IRCON = 0;
disable_interrupt();
void HexToAscii(unsigned char original,unsigned char *tempdata)
const unsigned char asctable[17] = "0123456789abcdef";
*tempdata = asctable[original>>4];
*(tempdata+1) = asctable[original & 0x0f];
void main(void)
unsigned char i=0;
uint8_t tempprintfdata[2];
uint8_t testdata[3];
//void (*JumpToApp)() = 0x086E;
// clock interupt
Init();
P0DIR &= 0xf7; // p0.3, uart_txd,output
hal_uart_init(UART_BAUD_57K6);
delay_ms(1000);
delay_ms(1000);
EA=1;
hal_uart_putstring("FPCR=");
HexToAscii(FPCR,tempprintfdata);
hal_uart_putchar(tempprintfdata[0]);
hal_uart_putchar(tempprintfdata[1]);
hal_uart_putstring("\r\n");
hal_uart_putstring("PCON=");
HexToAscii(PCON,tempprintfdata);
hal_uart_putchar(tempprintfdata[0]);
hal_uart_putchar(tempprintfdata[1]);
hal_uart_putstring("\r\n");
PCON |= PMW;
hal_flash_page_erase(30);
hal_flash_byte_write(0x3c00,0x55);
hal_flash_byte_write(0x3c01,0xaa);
hal_flash_bytes_read(0x3c00,testdata,3);
PCON &= ~PMW;
hal_uart_putstring("0x3c00=");
HexToAscii(testdata[0],tempprintfdata);
hal_uart_putchar(tempprintfdata[0]);
hal_uart_putchar(tempprintfdata[1]);
HexToAscii(testdata[1],tempprintfdata);
hal_uart_putchar(tempprintfdata[0]);
hal_uart_putchar(tempprintfdata[1]);
HexToAscii(testdata[2],tempprintfdata);
hal_uart_putchar(tempprintfdata[0]);
hal_uart_putchar(tempprintfdata[1]);
hal_uart_putstring("\r\n");
while(1);