AnsweredAssumed Answered

Hardfault during Expedited access using LPC CANAPI with -Os compiler optimization

Question asked by Raphael Meyer on Jul 3, 2017

Morning!

I'm implementing currently a firmware for a LPC11C14 MCU which should communicate with other nodes over CANopen.

Since the chip provides a CANopen API in its ROM, I decided to use it for my purpose according to the App note AN11238, LPC11Cxx CANopen network demo. Everything works fine so far as long as I compile the code with either the optimization -Od or -O1 to -O3. As soon as I compile the code with optimization for size activated (-Os), I get a hardfault during a CANopen Expedited request, segmented access works fine still. The hardfault even occurs when the callback function for the reqeusts is totally empty. Timingwise, the callback "CANopen_SDOS_Exp_Write" and "CANopen_SDOS_Exp_Read" is called correctly and returns normally. After the return of the callback, the MCU crashes.

 

Attached the code of the canopen library I'm using. Most parts are taken from the Appnote's driver, just some defines for better readability have been added as well as a method for adding entries to the object dictionary before the start of the CAN interface. Further, I attached the linker scripts.

Any ideas?

 

Regards, Raphael

Original Attachment has been moved to: canopen.h.zip

Original Attachment has been moved to: ldscripts.zip

Original Attachment has been moved to: can_node_sdo.c.zip

Original Attachment has been moved to: can_node_sdo.h.zip

Original Attachment has been moved to: canopen.c.zip

Outcomes