lpcware

LPC1114 - IAP ERASE PAGE - BUSY

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by masterboy on Thu Nov 06 01:26:20 MST 2014
Hi all,

I have a problem. I try use iap for erase page, but result is 1 = BUSY. What could be the problem? I tried it on a simple program:


#ifdef __USE_CMSIS
#include "LPC11xx.h"
#endif

#include <cr_section_macros.h>

#define IAP_LOCATION 0x1fff1ff1
#define IAP_PREPARE_SECTOR50
#define IAP_COPY_RAM_TO_FLASH51
#define IAP_ERASE_SECTOR52
#define IAP_BLANK_CHECK_SECTOR53
#define IAP_READ_PART_ID54
#define IAP_READ_BOOT_CODE_VERSION55
#define IAP_COMPARE56
#define IAP_REINVOKE_ISP57
#define IAP_READ_UID58
#define IAP_ERASE_PAGE59

#define PAGE_LEN256
#define SECTOR_NUM_PAGES16

unsigned int command_param[5];
unsigned int status_result[4];

typedef void (*IAP)(unsigned int [],unsigned int[]);
static const IAP iap_entry = (IAP)IAP_LOCATION;

volatile static uint8_t au8_buffer[256];

uint8_t u8_page = 96;

int main(void) {

command_param[0] = IAP_PREPARE_SECTOR;
command_param[1] = u8_page / SECTOR_NUM_PAGES;
command_param[2] = u8_page / SECTOR_NUM_PAGES;
iap_entry(command_param, status_result);

command_param[0] = IAP_COPY_RAM_TO_FLASH;
command_param[1] = u8_page * PAGE_LEN;
command_param[2] = &au8_buffer;
command_param[3] = PAGE_LEN;
command_param[4] = SystemCoreClock / 1000;
iap_entry(command_param, status_result);

command_param[0] = IAP_PREPARE_SECTOR;
command_param[1] = u8_page / SECTOR_NUM_PAGES;
command_param[2] = u8_page / SECTOR_NUM_PAGES;
iap_entry(command_param, status_result);

command_param[0] = IAP_ERASE_PAGE;
command_param[1] = u8_page;
command_param[2] = u8_page;
command_param[3] = SystemCoreClock / 1000;
iap_entry(command_param, status_result);

    while(1) {
    }
    return 0 ;
}

Outcomes