K22 Flash programming difficulty

cancel
Showing results for 
Search instead for 
Did you mean: 

K22 Flash programming difficulty

Jump to solution
964 Views
mjbcswitzerland
Specialist V

Hi All

I wonder whether anyone can explain why the Flash on my FRDM-K22F board won't program using the phrase program command?

When I run the same programming code on my FRDM-K64F it works normally.

This is what I do and see:

1. The FSTAT is at 0x80 (CCIF and ready)

2. I prepare for phrase programming (eg. programming 0x00000000 0x00000000 to 0x10000)

- FTFL_FCCOB0 = 0x07 (phrase programming command)

- FTFL_FCCOB1 = 0x01   [three bytes for the address 0x10000]

- FTFL_FCCOB2 = 0x00

- FTFL_FCCOB3 = 0x00

- FTFL_FCCOB4 = 0x00 [8 data bytes]

- FTFL_FCCOB5 = 0x00

- FTFL_FCCOB6 = 0x00

- FTFL_FCCOB7 = 0x00

- FTFL_FCCOB8 = 0x00

- FTFL_FCCOB9 = 0x00

- FTFL_FCCOBA = 0x00

- FTFL_FCCOBB = 0x00

3. The command is issued and FSTAT is 0xa0 (access error - bad address, wrong flash mode or protected)

The flash config is

ff ff ff ff ff ff ff ff ff ff ff ff fe ff ff f (that is, unsecured and no protection).

The address 0x10000 is phrase aligned and in flash so I haven't been able to work out why it is not working (all other K parts supporting phrase programming are Ok with the identical code and sequence).

Any ideas?

Regards

Mark

Labels (1)
1 Solution
319 Views
mjbcswitzerland
Specialist V

Hi All

OK - with a bit of trial and error I managed to make it work. But the problem is essentially in the user manual to the MK22F512VLH12 (64 pin package) as used on the FRDM-K22F. Actually, the fact is that there is no user manual to this part!!!! The documentation page is K22_120 |Kinetis K22 120 MHz MCUs|Freescale

There are the following user manuals there, the parts that they are valid for and the Flash granularity that they have:

K22P64M120F5 [FX512, FN1M] {4k granularity}

K22P80M120F5 [FX512, FN1M] {4k granularity}

K22P100M120F5 [FX512, FN1M] {4k granularity}

K22P121M120F5 [FX512, FN1M] {4k granularity}

K22P121M120F7 [FN512] {2k granularity}

K22P121M120F8 [FN256] {2k granularity}

K22P144M120F5 [FX512, FN1M] {4k granularity}

According to K22P64M120F5 (the only one for the 64 pin device) the Flash granularity is 4k and it uses phrase programming.

But it only works if long word programming is used (different command) and the actual flash granularity is 2k and not 4k.

Therefore a document called K22P64M120F7 [FN512] {2k granularity} is missing; or one needs to generally follow K22P64M120F5 but the use flash section from K22P121M120F.

Probably the user manual is simply missing from the page but in any case one has to tread carefully since the granularity changes between the parts, even in the same package.

Regards

Mark

View solution in original post

3 Replies
320 Views
mjbcswitzerland
Specialist V

Hi All

OK - with a bit of trial and error I managed to make it work. But the problem is essentially in the user manual to the MK22F512VLH12 (64 pin package) as used on the FRDM-K22F. Actually, the fact is that there is no user manual to this part!!!! The documentation page is K22_120 |Kinetis K22 120 MHz MCUs|Freescale

There are the following user manuals there, the parts that they are valid for and the Flash granularity that they have:

K22P64M120F5 [FX512, FN1M] {4k granularity}

K22P80M120F5 [FX512, FN1M] {4k granularity}

K22P100M120F5 [FX512, FN1M] {4k granularity}

K22P121M120F5 [FX512, FN1M] {4k granularity}

K22P121M120F7 [FN512] {2k granularity}

K22P121M120F8 [FN256] {2k granularity}

K22P144M120F5 [FX512, FN1M] {4k granularity}

According to K22P64M120F5 (the only one for the 64 pin device) the Flash granularity is 4k and it uses phrase programming.

But it only works if long word programming is used (different command) and the actual flash granularity is 2k and not 4k.

Therefore a document called K22P64M120F7 [FN512] {2k granularity} is missing; or one needs to generally follow K22P64M120F5 but the use flash section from K22P121M120F.

Probably the user manual is simply missing from the page but in any case one has to tread carefully since the granularity changes between the parts, even in the same package.

Regards

Mark

319 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello Mark:

I am glad you found the solution. I am sorry that the documentation caused you some troubles.

Actually the MK22FN512VLH12 (64 pin) is covered with the document K22P121M120SF7RM; in the first page you can see the devices supported. I don't know the exact naming convention, but It seems that in the past there was a unique document for each MCU package, while now the same document covers more than one package and it is named after the highest pin-count part.

Especially with K22_120 MHz parts, this has caused a lot of confusion, that's why I created the next document:

Kinetis K22_120 MHz devices

Regards!

Jorge Gonzalez

319 Views
mjbcswitzerland
Specialist V

Hi Jorge

Thanks. I will be more careful in the future and search all manuals to match the exact parts first.

I think the confusing thing is that if the manual is related to the largest part one would possibly expect K22P100M120F5 to then contain 100 pin, 80 pin and 64 pin but there are individual manuals for the 80 and 64 pin ones. That the K22P121M120F7 is nevertheless valid for 121 and 64 pins is not intuitive when the previous point is known.

However, there are various differences between the K22 parts which more likely depicts which user manual they actually best fit in so it is certainly safest to first ensure that the exact part is listed rather than jumping to any conclusions and possibly regretting it after a few hours of unexpected debugging. Not a problem now since I am the wiser (once bitten, twice shy;-)

Regards

Mark