Hi,
I am planning to add CAN2 to SLN_LOCAL2 and I am able to initialise the CAN communication but not able to transmit can message and it gets struck at this line "while (!FLEXCAN_GetMbStatusFlags(CAN2, 1 << FrameTx));"
/*******************************************************************************
* Initialise CAN
******************************************************************************/
void CAN_INIT()
{
/* Initialise CAN */
flexcan_config_t flexcanConfig;
flexcanConfig.clksrc=kFLEXCAN_ClkSrc0;
flexcanConfig.baudRate = 50000U;
flexcanConfig.maxMbNum = 16;
flexcanConfig.enableLoopBack = false;
flexcanConfig.enableSelfWakeup = false;
flexcanConfig.enableIndividMask = false;
flexcanConfig.disableSelfReception = false;
flexcanConfig.enableListenOnlyMode = false;
flexcanConfig.enableDoze = false;
FLEXCAN_Init(CAN2, &flexcanConfig, 80000000UL);
configPRINTF(("\r\nCAN initialized"));
/* Enable FlexCAN module. */
FLEXCAN_Enable(CAN2, true);
}
/*******************************************************************************
* CAN Transmit Function
******************************************************************************/
void CAN_SEND(long CANID,char m1,char m2,char m3,char m4,char m5,char m6,char m7,char m8,int CANDLC)
{
status_t status1;
flexcan_frame_t txFrame;
/* Enable FlexCAN module. */
uint8_t FrameTx=1UL;
FLEXCAN_Enable(CAN2, true);
/* Sets up the transmit message buffer. */
FLEXCAN_SetTxMbConfig(CAN2, FrameTx, true);
/* Prepares the transmit frame for sending. */
txFrame.format = kFLEXCAN_FrameFormatStandard;
txFrame.type = kFLEXCAN_FrameTypeData;
txFrame.id = FLEXCAN_ID_STD(CANID);
txFrame.length = CANDLC;
txFrame.dataWord0 = CAN_WORD0_DATA_BYTE_0(m1) |
CAN_WORD0_DATA_BYTE_1(m2) |
CAN_WORD0_DATA_BYTE_2(m3) |
CAN_WORD0_DATA_BYTE_3(m4);
txFrame.dataWord1 = CAN_WORD1_DATA_BYTE_4(m5) |
CAN_WORD1_DATA_BYTE_5(m6) |
CAN_WORD1_DATA_BYTE_6(m7) |
CAN_WORD1_DATA_BYTE_7(m8);
/* Writes a transmit message buffer to send a CAN Message. */
status1=FLEXCAN_WriteTxMb(CAN2, FrameTx, &txFrame);
configPRINTF(("\r\nCAN Message sent %d",status1));
/* Waits until the transmit message buffer is empty. */
while (!FLEXCAN_GetMbStatusFlags(CAN2, 1 << FrameTx));
/* Cleans the transmit message buffer empty status. */
FLEXCAN_ClearMbStatusFlags(CAN2, 1 << FrameTx);
}
This is the example code from SDK. I was having proble in initialise CAN clock and initialised UART clock and the problem dissapeard is it something to do with it.
Does any one has sample or example code in FreeRTOS?
Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
To provide the fastest possible support, I'd highly recommend you to refer to the below demos in the SDK library for the MIMXRT1060 EVK, as it needs to adjust the above code architecture to integrate the FreeRTOS.
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hello,
After adjusting clock the CAN Initialisation is done and I am transmitting CAN messages but the IFLAG1 is not set and it is transmitting continously.
CAN Tx signal:
but the IFLAG is not set, so its looping and continously transmitting.
I also see this, is it MCUxpresso problem or debugger?
the macro is defined but some how the line is skipped I could not understand but the pheriperal clock has value defined.
P.S: I am using CAN2 as the voice demo has serial output connetor with lpuart6.