By the way, I changed my FlashKLxx32K.flash file from:
<?xml version="1.0" encoding="iso-8859-1"?>
<flash_device>
<exe>$TOOLKIT_DIR$\config\flashloader\Freescale\FlashKLxx.out</exe>
<page>4</page>
<block>32 0x400</block>
<flash_base>0x00000000</flash_base>
<macro>$TOOLKIT_DIR$\config\flashloader\Freescale\FlashKLxx.mac</macro>
<online>1</online>
<aggregate>1</aggregate>
<args_doc>--enable_config_write - allow programming of 0x40C - 0x40F with user supplied
data, in other case flashloader after erase of block 1 will write 0xFFFF_3DFE
(unsecure state).</args_doc>
</flash_device>
...to...
<?xml version="1.0" encoding="iso-8859-1"?>
<flash_device>
<exe>$TOOLKIT_DIR$\config\flashloader\Freescale\FlashKLxx2K.out</exe>
<page>4</page>
<block>32 0x400</block>
<flash_base>0x00000000</flash_base>
<macro>$TOOLKIT_DIR$\config\flashloader\Freescale\FlashKLxx.mac</macro>
<online>1</online>
<aggregate>1</aggregate>
<args_doc>--enable_config_write - allow programming of 0x40C - 0x40F with user supplied
data, in other case flashloader after erase of block 1 will write 0xFFFF_3DFE
(unsecure state).</args_doc>
</flash_device>
...and now I can upload my code. However, as soon as the upload is finished several error windows popup and this is in the IAR SDK log:
---
Mon Dec 12, 2016 14:33:35: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.3\arm\config\debugger\Freescale\KLxx.dmac
Mon Dec 12, 2016 14:33:35: Loaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.3\arm\config\flashloader\Freescale\FlashKLxx.mac
Mon Dec 12, 2016 14:33:41: P&E Interface detected - Flash Version 9.41
Mon Dec 12, 2016 14:33:43: Device is Freescale_KL0x_KL03Z32M4.
Mon Dec 12, 2016 14:33:43: Mode is In-Circuit Debug.
Mon Dec 12, 2016 14:33:43: Initial reset was performed
Mon Dec 12, 2016 14:33:43: CPU reset by debugger.
Mon Dec 12, 2016 14:33:43:
Mon Dec 12, 2016 14:33:43: Software reset was performed
Mon Dec 12, 2016 14:33:43: Watchdog disabled
Mon Dec 12, 2016 14:33:43: 768 bytes downloaded and verified (3.69 Kbytes/sec)
Mon Dec 12, 2016 14:33:43: Loaded debugee: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.3\arm\config\flashloader\Freescale\FlashKLxx2K.out
Mon Dec 12, 2016 14:33:43: Target reset
Mon Dec 12, 2016 14:33:47: Unloaded macro file: C:\Program Files (x86)\IAR Systems\Embedded Workbench 7.3\arm\config\flashloader\Freescale\FlashKLxx.mac
Mon Dec 12, 2016 14:33:47: The flash loader program reported an error.
---
Any help is appreciated.