AnsweredAssumed Answered

I'm not able to erase flash sector in MKL03,error 0x20

Question asked by Diego Colombo on Jun 23, 2018
Latest reply on Jul 16, 2018 by Jorge Antonio Alcala Vazquez

Hi,i need help in erasing and writng some data in a  sector of this small microcontroller,MKL03Z8VFG4


i dont know where is my error,but probably is very big.
I'm trying to erase a sector using the fsl_flash component in KDS 3.0.0 with KSDK
Actually how dont'know exactly how to use this component.

FlashInit(&flash1_InitConfig0);
  PFlashGetProtection(&flash1_InitConfig0,&protect_state);
  __asm("cpsid i");
  i=FlashEraseSector(&flash1_InitConfig0,0x1C00,1024,FlashCommandSequence);
  __asm("cpsie i");

i results 0x20  
The settings of the Processor Expert are at low clock frequency(4 MHz core clock and 2 MHz bus clock).

I reserved a sector in Flash at 0x1C00,modifyng the linker file,

m_text (RX) : ORIGIN = 0x00000410, LENGTH = 0x000017F0
my_flash (RX) : ORIGIN = 0x00001C00, LENGTH = 0x00000400
at the beginning of this sector some data was written at programming time,so to check if erasing happens.

unsigned char __attribute__((section (".myBufSection"))) buf[150]={"abcdefghijklmno

In the . s files these ares the configuration settings
.section .FlashConfig, "a"
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFFFFFF
.long 0xFFFF3DFE

I think that the "3D" value has to do only with the NMI enable and boot options,
the FTFA_FPROTn register are all0xFFFFFFFF,meaning that no region is protected

 

The example project is attached, if someone kindly would chek it,thanks;it is from a project that i cleaned almost to essential just to test the flash functions.

Many thanks.

Attachments

Outcomes