AnsweredAssumed Answered

IntFlash Processor Expert component in CW10, Coldfire V1

Question asked by antoniomagrì on Jul 5, 2017
Latest reply on Jul 27, 2017 by ZhangJennie

I am developing a project with MCF51AC256A, using Codewarrior 10.7 with Processor Expert.


I use a IntFlash component to store some data in the device (calibration settings, little bits of diagnostic information) that must survive between power cycles.


I recently discovered that whenever my application tried to write to flash the CPU would reset. I had changed nothing in the software related to flash management, and moreover the actual code that manages the writes is generated by Processor Expert so I was a little puzzled.

When I started debugging I could see that something was wrong with the FnCmdInRam_ routine that the PE code copies to the stack and executes to actually perform operations with the Flash controller.


I could see that something was different between the original function in flash and the copy in the stack. I will spare you all the investigation and jump to the conclusion:


the PE code creates a structure in the stack with a fixed size:


typedef struct {
  byte code[0x36];                     /* Structure required to copy code to ram memory */
  /* Size of this structure needs to be at least (but best) the size of the FnCmdInRam_ */
} TFnCmdInRamStruct;
but when I changed the Optimization setting for the Coldfire compiler from "size" to "speed" the size of the function jumped from 
00000410 0000002C .text   FnCmdInRam_    (IFsh1_c.obj)


00000410 00000038 .text   FnCmdInRam_    (IFsh1_c.obj)

so the function would not fit into the RAM structure any longer!

I was able to solve this issue by disabling code generation for the component and manually increasing the structure size.


But! I have a question for the PE folks... would it be possible to have a correct behavior out of the box? It seems strange to me that changing the optimization setting would break the component, without at least a warning...