Flash programming on MKL16z256,

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

Flash programming on MKL16z256,

1,160 Views
josrennies
Contributor I

I need help on programming the internal flash of an MKL16z256 device. The idea is to store 1k bytes at the end of the flash memory. I am working in expert mode, so a piece of sample code on this or a guideline would be nice.

Here is what I have tested so far:

IFsh1_EraseSector( 0x20000);
IFsh1_SetBlockFlash(TX_buff,0x20000,32);
IFsh1_SetByteFlash(0x20000,'J');

 IFsh1_SetByteFlash(0x20001,'O');
IFsh1_SetByteFlash(0x20002,'S');
int k=0;

char b,bb;
for (k=0;k<3;k++){
   b=IFsh1_GetByteFlash(0x20000+k,&bb);
   AS1_SendChar(bb);
   delay_ms(100);
}

Thanks

Labels (1)
0 Kudos
6 Replies

884 Views
mjbcswitzerland
Specialist V

Hi

The KL parts use long word programming so I suspect that you may be having problems programming single bytes to a long word as in your example.


See the parameter system described in http://www.utasker.com/docs/uTasker/uTaskerFileSystem_3.PDF (sections 7, 8 and 9) for some general information about this topic.

Regards

Mark
Kinetis for professionals: http://www.utasker.com/kinetis.html

0 Kudos

884 Views
josrennies
Contributor I

Dear Mark,

The implementation of the initial flash routine using the long word , as suggested did not flash the data.

(I've adapted the functions to towards long word call.).

Do you have any other suggestion or example code?

Thanks,

jos

0 Kudos

884 Views
mjbcswitzerland
Specialist V

Jos

Make sure that you're not trying to flash anything in a long word that has already been written to - this will cause an error.

I have attached the Flash driver from the uTasker project which will work on any KE,KEA,KL,KV,KM,K part for your reference. It also contains the parameter system code referenced in the document.

Regards

Mark

0 Kudos

884 Views
josrennies
Contributor I

Hello Mark,

Make sure that you're not trying to flash anything in a long word that has

already been written to - this will cause an error.

-


> I've checked and tried it with long word + using the erase function :

result is the same.

Question:

- is there shadow ram that must be handled and set?

- it is not 100% clear if there are flash write protect bits or other

settings to be turned off /on?

I only need a small piece of code to program and read back some bytes or

longwords. Nothing seems to be available on application notes or

sample/example c code for this.

wbr,

Jos

On Thu, Oct 13, 2016 at 12:58 PM, mjbcswitzerland <

0 Kudos

884 Views
mjbcswitzerland
Specialist V

Jos

I attached C code to the last post that I have used on more than 100 different Kinetis parts (and uTasker users have used in many industrial projects for several years).

There are binary images for most NXP Kinetis boards at the link at the bottom of the other posts so you can also load one to a board that you have and play around with reading, writing, erasing memory  - this link explains the general interface on the debug UART which can be used for any internal or external memory types:
http://www.utasker.com/kinetis/KE_EEPROM.html

There is no shadow RAM to be worked with and as long as you haven't protected sectors in your Flash configuration you should have no problems manipulating internal memory.

Load working code and analyse the operation or run the uTasker simulator since it also emulates internal Flash so that you can see the details.

Regards

Mark

0 Kudos

884 Views
josrennies
Contributor I

Mark, thanks for your prompt reaction, I'll try out your proposal.

wbr,

Jos

On Thu, Oct 13, 2016 at 12:58 PM, mjbcswitzerland <

0 Kudos