Not able to write in flash of LPC18S37

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Not able to write in flash of LPC18S37

5,297 次查看
PranavKolte1
Contributor II

Hi
I am using lpc18s37 micro controller for development. I am trying to erase and write in flash using IAP method but not able to do so. Can anyone help me with this, below is the code that is written.

#if defined (__USE_LPCOPEN)

#if defined(NO_BOARD_LIB)

#include "chip.h"

#else

#include "board.h"

#include "chip.h"

#endif

#endif

 

#include <cr_section_macros.h>

 

// TODO: insert other include files here

#include "stdio.h"

#include "string.h"

 

#define START_ADDRESS 0x1B000000

#define END_ADDRESS 4096

 

// TODO: insert other definitions and declarations here

 

int main(void) {

 

#if defined (__USE_LPCOPEN)

// Read clock settings and update SystemCoreClock variable

SystemCoreClockUpdate();

#if !defined(NO_BOARD_LIB)

// Set up and initialize all required blocks and

// functions related to the board hardware

Board_Init();

// Set the LED to the state of "On"

Board_LED_Set(0, true);

#endif

#endif

 

 

// TODO: insert code here

// Board_Debug_Init();

 

uint32_t sector_end = START_ADDRESS + END_ADDRESS - 1;

Chip_IAP_PreSectorForReadWrite(START_ADDRESS, sector_end, IAP_FLASH_BANK_B);

Chip_IAP_EraseSector(START_ADDRESS, sector_end, IAP_FLASH_BANK_B);

uint32_t buffer[] = {0xFF, 0x01, 0x02, 0x03, 0xAA};

Chip_IAP_CopyRamToFlash(START_ADDRESS, buffer, sizeof(buffer));

 

while(1)

{

}

return 0 ;

}

标签 (2)
0 项奖励
回复
6 回复数

5,274 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @PranavKolte1 

Recommend refer to "flashiap" demo under LPCopen.

If you still have question about it, please kindly let me know.

 

BR

Alice

5,258 次查看
PranavKolte1
Contributor II

Thank You for the help! I referred that and now able to do that.

Can yo please help me to write or erase in flash using ISP protocol. I am trying to build my own boot loader.

0 项奖励
回复

5,226 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @PranavKolte1 

Your own second bootloader should use iap, not ISP. the ISP command is used for boot ROM.

In ISP mode, using ISP command. Can using Flash Magic tool on PC side.

 

BR

Alice

5,218 次查看
PranavKolte1
Contributor II

Hello @Alice_Yang

Can you pls point me to the detail documentation for regarding the ISP, IAP and BOOT ROM.

0 项奖励
回复

5,199 次查看
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @PranavKolte1 

Refer to User Manual for lpc18s37, Chapter 4: LPC18xx Boot ROM and Chapter 5: LPC18xx flash programming/ISP and IAP. I attach it for you.

 

BR

Alice

5,095 次查看
PranavKolte1
Contributor II

 

Hello @Alice_Yang 

I am trying to write Secondary Bootloader for LPC1823 microcontroller can you pls point me to the documentation regarding the secondary bootloader for LPC1823. I want to use USB0 in DFU mode for receiving data from PC.

0 项奖励
回复