Laartoor

KSDK2.1 Issues with flexcan/sim

Discussion created by Laartoor on Dec 1, 2016

I believe I have encountered two errors with KSDK2.1. I am using it with a K64.

 

a) In the function FLEXCAN_SetRxFifoConfig in fsl_flexcan.c, the original value of setup_mb is one too low. setup_mb is the number of configured message buffers, and an assert later checks that we have at least one transmit message buffer available. But the initial set is 

setup_mb = (base->MCR & CAN_MCR_MAXMB_MASK) >> CAN_MCR_MAXMB_SHIFT;

and this sets the index of the highest available message buffer, which is one lower than the count.

I encountered the problem with a setup of 9 message buffers, and an rx fifo with 8 filters, thus exactly one transmit buffer.

 

b) in fsl_sim.h, we have the definition

/*!@brief Unique ID. */
typedef struct _sim_uid
{
#if defined(SIM_UIDH)
    uint32_t H; /*!< UIDH.  */
#endif
    uint32_t MH; /*!< UIDMH. */
    uint32_t ML; /*!< UIDML. */
    uint32_t L;  /*!< UIDL.  */
} sim_uid_t;

But at least for the K64, SIM_UIDH is not defined, but SIM_UIDH_UID is in MK64F12.h

Outcomes