AnsweredAssumed Answered

K22 and IAR - Stack pointer is setup to incorrect alignment

Question asked by weblar on Jun 13, 2014
Latest reply on Jun 13, 2014 by weblar



I have a puzzling problem.


For the past 2 weeks, I've been downloading and debugging code written for a Kinetis K22 device through IAR v6.40. I did have to manually copy across the supporting K22 files from a later version of an IAR trial as the K22 doesn't have the support files in 6.40 - however, this has been working perfectly for the past 2 weeks, i.e. USB CDC device working, OLED display via FlexBus, etc, etc.


All of a sudden, I am no longer able to debug because of the following error when trying to download the binary to the device:


Warning: Stack pointer is setup to incorrect alignment. Stack addr = 0xFFFFFFFF


I've tried to create a new, simple project with just a main function targetting the same K22 device however this also fails with the same issue when downloading and debugging via the Segger J-Link. I had thought that the device could be securely locked so today I replaced the chip however this has made no difference. The map file generated by the compiler seems absolutely fine.

I am sometimes able to download to the device using Seggers own J-Flash utility however this is quite flaky, the device takes a long time to reset but when it does download, the application runs as expected.


Having torn pretty much the last of my remaining hair from my head, I can't even begin to think what could have changed. The obvious answer is nothing, I've not updated any drivers or J-Link firmware, nor IAR updates.


Please please please can someone help me with this.