SPI Slave fails when code is built with -O1 optimized flag

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

SPI Slave fails when code is built with -O1 optimized flag

909 Views
cwati
Contributor III

Hi there,


We're using MK22FN256xxx12, running bare metal KSDK 1.0.0 (I know it's old, but we don't have the resource to update it yet).  The SPI on this board is running as a slave to a master (Nordic NRF51822 chip).  When the Kinetis code is built regularly, everything runs ok.  But recently we're short on space so I tried to build with optimized (I tried specifically with "-O1").  When I do that, then SPI slave starts failing.  The data coming into K22F is okay generally, but the data going to Nordic is so messed up it's unusable.

Has anyone ever experienced this?  Is this caused by something trivial, perhaps some Compiler settings that I can modify?

In general I do see when building with Optimized (C/C++ Build->Settings->Optimization Level->Optimize...) then the system degenerates.  But I've never tried to pinpoint exactly where it's happening.  This time, it's very reproducible and obvious.

Thanks,
Cecylia

Labels (1)
0 Kudos
Reply
2 Replies

727 Views
cwati
Contributor III

Seems like my code works better if I choose to disable loop invariant move.

pastedImage_1.png

0 Kudos
Reply

727 Views
Carlos_Mendoza
NXP Employee
NXP Employee

Hi Cecylia,

It is good to hear you found a workaround. Since KSDK 1.0.0 is an old version, it is no longer available for download so I can't reproduce what you mention. I would recommend that you use the new MCUXpresso SDK 2.x, there have been some bug fixes and improvements since version 1.0.0.


Hope it helps!

Best Regards,
Carlos Mendoza
Technical Support Engineer

0 Kudos
Reply