LPC1788 IAP Problem

I'm working on LPC1788, trying to use In Application Programming, and in one project where I implemented this code:

#define IAP_BASE1 0x00030000 #define IAP_BASE2 0x00038000 #define IAP_BASE3 0x00040000

int main(void) {

BYTE podatak1, podatak2, podatak3; DWORD *pointer_podatak1, *pointer_podatak2, *pointer_podatak3; uart0();


podatak1 = 0x33; podatak2 = 0x63; podatak3 = 0x84;

iap_copy_to_flash(&podatak1, IAP_BASE1, 1); delay_1_ms(); iap_copy_to_flash(&podatak2, IAP_BASE2, 1); delay_1_ms(); iap_copy_to_flash(&podatak3, IAP_BASE3, 1); delay_1_ms();

pointer_podatak1 = (DWORD*) IAP_BASE1; pointer_podatak2 = (DWORD*) IAP_BASE2; pointer_podatak3 = (DWORD*) IAP_BASE3;

LPC_UART0->THR = *pointer_podatak1; delay_1_ms(); LPC_UART0->THR = *pointer_podatak2; delay_1_ms(); LPC_UART0->THR = *pointer_podatak3; delay_1_ms();

while(1) { }


It works perfectly, but when I try to utilize it in my main project, I've got nothing written on flash memory locations I indicated. Here is the code in my main project to read and write from flash:

#define OFFSET_ADDRESS 0x00030000 #define OFFSET_VERSION 0x00038000 #define OFFSET_SERIAL 0x00040000

void write_to_flash (void) { BYTE i; DWORD *pointer_podatak1, *pointer_podatak2, *pointer_podatak3;

iap_copy_to_flash(&display_address, OFFSET_ADDRESS, 1); delay_1_ms();

iap_copy_to_flash(&version, OFFSET_VERSION, 1); delay_1_ms();

for (i=0;i MAX_OUTDOOR_DISPLAY_ADDRESS) || (display_address < MIN_OUTDOOR_DISPLAY_ADDRESS)) display_address = UNI_ADDRESS;

pok_ver = (DWORD*)OFFSET_VERSION; version = *pok_ver; delay_1_ms(); if (version > MAX_FW_VERSION) version = 0;

for (i=0;i

Reply to
Loading thread data ...

I've not used this particular part, however:

- you say "works perfectly", but you do not check the return codes from write operation?

- did you previously "prepare" and "erase" the sectors? See page 896 in the manual you linked...

Hope that helps! Best Regards, Dave

Reply to
Dave Nadler

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.