Can I use the same external SPI flash to store program memory and for storage of some data?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can I use the same external SPI flash to store program memory and for storage of some data?

896 Views
NVazquez
Contributor IV

I am using LPC54016 on custom board with external flash SPI(Winbond- W25Q32JVSS). As LPC540xx doesn't have an internal flash memory, can I use a part of ext flash to store the program memory and another part to store some data?

0 Kudos
Reply
3 Replies

887 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Regarding your question, I think it is complicated, we have to discuss case by case

As you know that the LPC54016 does not have on-chip flash, all the code and constant data must be put on external spifi flash.

case 1:

If you define constant data like const uint32_t array[10]={1,2,3,4,5,6,7,8,9,10}; The array will be put into external spifi flash when you download code to flash, you can read the array no matter whether you run the code in internal RAM or XIP.

 

Case 2: Assume you want to write external spifi flash in application code, if you run the code in on-chip RAM(you download code to spifi flash, copy the code to on-chip RAM, and run in on-chip RAM), it is okay to erase/program spifi flash as the example code spifi_polling_transfer.  If you run the code in external spifi flash(XIP mode), it is impossible  to erase/program spifi flash.

Hope it can help you

BR

XiangJun Rong

 

 

 

 

0 Kudos
Reply

878 Views
NVazquez
Contributor IV

Thank you for your reply!

 

In case 2: Assume you want to write external spifi flash in application code, if you run the code in on-chip RAM(you download code to spifi flash, copy the code to on-chip RAM, and run in on-chip RAM), it is okay to erase/program spifi flash as the example code spifi_polling_transfer.  If you run the code in external spifi flash(XIP mode), it is impossible  to erase/program spifi flash

 

Just want to make sure I understood,

 

1.  I will copy the code in spi flash and in on-chip RAM

2. Then I can write/erase the spi flash not the code memory location but some other location using the example code spifi_polling_transfer.

3. Now when I power cycle, as on-chip RAM is volatile memory, how will the controller know to just copy the code from code memory location to ON chip RAM, and not to touch the static data I wrote before power cycle?

0 Kudos
Reply

873 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

As you know that the application code and constant data are saved in external spifi flash as an image, in the image, there are a lot of marks, which tell the bootloader code the image size, the destination address you want to copy.

After power-up, the bootloader which is located in on-chip ROM runs firstly, the bootloader read the image and copied the application code to on-chip RAM and jump to RAM and execute in on-chip RAM, at the time, the spifi flash is idle, so you can erase/program the spifi flash.

It is upon to you to determine where to erase/program constant based on your code you have used

Pls refer to the an12122.pdf for the image format for LPC540xx family

https://www.nxp.com.cn/docs/en/application-note/AN12122.pdf

 

Hope it can help you

BR

XiangJun Rong

 

0 Kudos
Reply