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