I’m trying to send data over the CAN bus with the flexcan_network example. When running this example however, the program never even executes the BOARD_FLEXCAN_HANDLER and i can’t seem to find out why.
I connected the FLEXCAN2 RX and TX pins(UNO_I2C_SCL and UNU_I2C_SDA) to an MCP2562 and tried to read out the data with a scope, however this does not show any data either.
I know that the BOARD_FLEXCAN_HANDLER is defined as the interrupt handler for FLEXCAN2, but i still can’t seem to figure out how this works exactly.
How can i make it so that this example will send data to the CAN bus?
BOARD_FLEXCAN_HANDLER is just a preprocessor define which gets replaced with FLEXCAN2_Handler. This function is then registered as a interrupt handler in platform/devices/MCIMX7D/startup/gcc/startup_MCIMX7D_M4.S. The interrupt handler should work.
Currently the FlexCAN examples are not well prepared for the Colibri platform. Depending on which pins you are using FlexCAN instance 2 might be the wrong one. For SODIMM 63/55 FlexCAN instance 1 needs to be used. Also pin muxing in examples/imx7_colibri_m4/pin_mux.c needs to be adjusted.
I added the changes, and tried to recompile it, and connect the RX and TX pins to UNO_GPIO7 and UNO_GPIO6 but i still don’t get any response on the scope.
It seems to crash in the FLEXCAN_Init function.
Is there anything else needed for this example to send data over the CAN Bus?
The FLEXCAN_Init executes FLEXCAN_Disable. In this function, the while loop while (!(CAN_MCR_REG(base) & CAN_MCR_LPM_ACK_MASK)); will be stuck forever. This is because for some reason the LPM_ACK bit will never be set in the MCR register. It seems unlikely that the module is still waiting for a message, as this is still in the initialization phase.
When i remove this FLEXCAN_Disable the FLEXCAN_Init executes correctly, however the BOARD_FLEXCAN_HANDLER will never be called, which i think means that the transmit interrupt is not generated. I have no idea why this could be though.