CAN2 tx/rx issue in mxrt1050 evk board

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN2 tx/rx issue in mxrt1050 evk board

541 Views
Maheshkadam9922
Contributor II

here we were developing CAN2 rx, tx code in evk mimxrt1050, so we have query that what is use of CAN_STBY? how to configure?
here we configure FlexCAN2 pin and STB pin below:

//** PIN configuration flex can2 on mxrt1050
 
void BOARD_InitPins(void) {
  CLOCK_EnableClock(kCLOCK_Iomuxc);
 
  /* GPIO configuration of CAN_STB_PIN on GPIO_AD_B0_05  */
    gpio_pin_config_t CAN_STB_PIN_config = {
        .direction = kGPIO_DigitalOutput,
        .outputLogic = 0U,
        .interruptMode = kGPIO_NoIntmode
    };
 
   /* Initialize GPIO functionality on GPIO_AD_B0_05 */
    GPIO_PinInit(GPIO1, 1U, &CAN_STB_PIN_config);
 
  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_05_GPIO1_IO05, 0U);
 
 
 
  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_12_LPUART1_TXD, 0U);
  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_13_LPUART1_RXD, 0U);
  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_14_FLEXCAN2_TX, 1U);
  IOMUXC_SetPinMux(IOMUXC_GPIO_AD_B0_15_FLEXCAN2_RX, 1U);
  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_12_LPUART1_TXD, 0x10B0U);
  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_13_LPUART1_RXD, 0x10B0U);
  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_14_FLEXCAN2_TX, 0x10B0U);
  IOMUXC_SetPinConfig(IOMUXC_GPIO_AD_B0_15_FLEXCAN2_RX, 0x10B0U);
}
 
 here the CAN2 init function below:
 

static void CAN2_init(void) {
FLEXCAN_Init(CAN2_PERIPHERAL, &CAN2_config, CAN2_CLOCK_SOURCE);
/* Message buffer 9 initialization */
FLEXCAN_SetRxMbConfig(CAN2_PERIPHERAL, 9, &CAN2_rx_mb_config_0, true);
/* Message buffer 10 initialization */
FLEXCAN_SetTxMbConfig(CAN2_PERIPHERAL, 10, true);

FLEXCAN_SetRxIndividualMask(CAN2_PERIPHERAL, 9, FLEXCAN_RX_MB_STD_MASK(0x1AA, 0, 0));
}

also we set below parameter for CAN INIT anf MB configuration:

const flexcan_config_t CAN2_config = {
.wakeupSrc = kFLEXCAN_WakeupSrcUnfiltered,
.bitRate = 1000000UL,
.maxMbNum = 16U,
.enableLoopBack = false,
.enableTimerSync = true,
.enableSelfWakeup = false,
.enableIndividMask = false,
.disableSelfReception = false,
.enableListenOnlyMode = false,
.enableSupervisorMode = false,
.timingConfig = {
.preDivider = 2,
.propSeg = 1,
.phaseSeg1 = 3,
.phaseSeg2 = 2,
.rJumpwidth = 1
}
};
/* Message buffer 0 configuration structure */
const flexcan_rx_mb_config_t CAN2_rx_mb_config_0 = {
.id = FLEXCAN_ID_STD(0x1AA),
.format = kFLEXCAN_FrameFormatStandard,
.type = kFLEXCAN_FrameTypeData
};

also we use interrupt feature, code is below:

FLEXCAN_EnableMbInterrupts(CAN2_PERIPHERAL,9);
/* Enable interrupt CAN1_IRQn request in the NVIC. */
EnableIRQ(CAN2_IRQn);

 

also write a ISR function below:

void CAN2_FLEXCAN_IRQHANDLER(void)
{
 
/* If new data arrived, check Mb Status Flag */
if (0U != FLEXCAN_GetMbStatusFlags(CAN2_PERIPHERAL, 9))
{
/* Clear Mb Status Flag */
FLEXCAN_ClearMbStatusFlags(CAN2_PERIPHERAL, 9);
/* Read Message From Mb */
FLEXCAN_ReadRxMb(CAN2_PERIPHERAL,  9, &rxFrame);
rxComplete = true;
}
 
/* ISR exit barrier */
SDK_ISR_EXIT_BARRIER;
}
 
issue that our TX ,RX function not receive 
same code on custom board mxrt1051 its working , we have use same code only change the pin configuration . 
0 Kudos
Reply
1 Reply

520 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @Maheshkadam9922,

what is use of CAN_STBY? how to configure?

In IMXRT1050-EVKB's schematic the GPIO_AD_B0_05 goes to CAN_STBY, Flash_RST and BOOT_MODE[1].

RaulRomero_0-1687204498696.png

 [IMXRT1050-EVKB schematic p5]

CAN_STBY goes to TJA1057 High-speed CAN transceiver's pin S which is used to select the operating mode of the transceiver between Normal and Silent.

RaulRomero_1-1687204498704.png

[IMXRT1050-EVKB schematic p8]

Nonetheless, if you look closely to the schematic, CAN_STBY is open due the absence of R92 (DNP - Do not populate). If you want to use this functionality you may want to place a resistor in your EVK, in other case, CAN will work in Normal mode as Pin S is set to Low.

RaulRomero_2-1687204498707.png

[TJA1057 Product data sheet. Table 2. Boot mode pin settings]

For further information about the TJA1057 you could read the Product data sheet here.

 

issue that our TX ,RX function not receive 

Could you please try your code without configuring CAN_STBY (GPIO_AD_B0_05)?

GPIO_AD_B0_05 in the EVK goes to BOOT_MODE[1] is necessary for the EVK to boot, because is used to select which boot mode will be used. Using the same pin in other way may cause conflict in the EVK.

RaulRomero_3-1687204498710.png

[MIMXRT1050 EVK Board Hardware User's Guide. Table 2. Boot Mode pin settings]

Best regards, Raul.

0 Kudos
Reply