JN5189 FLASH_Erase()

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

JN5189 FLASH_Erase()

Jump to solution
728 Views
kuanyc
Contributor II

Hi,

I've been referencing flash_test.c to test the Flash memory options on #JN5189. In general the methods work as per the examples

However, I've a couple of questions regarding the use of the functions from fsl_flash.c

1. Is it always a must to precede each FLASH_Program() with either a FLASH_Erase() or FLASH_ErasePages()? i.e can we call consecutive FLASH_Program(), without calling FLASH_Erase() in between, with different pu32Start addresses even within the same page?

2. Instead of using FLASH_ErasePages() to erase entire pages, how can we use FLASH_Erase() to just erase a range of address from pu8Start to pu8End? 

For eg. If I only want to erase the data from 0x10000 to 0x10004. Will calling FLASH_Erase (FLASH, 0x10000, 0x10004) do the trick? How to cast those addresses to uint8 as defined for this function?

Hope to get some help in the use of these flash functions.

Thanks in advance.

Labels (1)
  • JN

0 Kudos
1 Solution
678 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @kuanyc,

It is not necessary to precede each FLASH_Program() with an Erase if it isn't in the same start address, but each page must be erased before it is programmed. Yes, consecutive Program can be done with different start addresses.

If you look into the FLASH_ErasePages() function, you can actually see it uses FLASH_Erase() after calculating the addresses (and casting the start address with (uint8_t *)). Utilizing FLASH_ErasePages() is suggested instead.

Best regards, Julián

View solution in original post

0 Kudos
2 Replies
679 Views
Julián_AragónM
NXP TechSupport
NXP TechSupport

Hi @kuanyc,

It is not necessary to precede each FLASH_Program() with an Erase if it isn't in the same start address, but each page must be erased before it is programmed. Yes, consecutive Program can be done with different start addresses.

If you look into the FLASH_ErasePages() function, you can actually see it uses FLASH_Erase() after calculating the addresses (and casting the start address with (uint8_t *)). Utilizing FLASH_ErasePages() is suggested instead.

Best regards, Julián

0 Kudos
673 Views
kuanyc
Contributor II

Hi @Julián_AragónM ,

Thanks for the guidance. I'll use FLASH_ErasePages() as suggested.