S32K116 CAN wake up

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

S32K116 CAN wake up

2,117 Views
yujinsheng
Contributor I

I've looked at it    Example S32K116 FlexCAN PN STOP S32DS.ARM.2.2 

I'm using the 2018.R1 IDE.  3.0 sdk

When I use JLink Debug, I can receive messages through CAN to wake up, but When I remove Jlink debugging, CAN cannot wake up after receiving messages.


const flexcan_user_config_t canCom1_InitConfig0 = {
    .fd_enable = false,
    .pe_clock = FLEXCAN_CLK_SOURCE_PERIPH,
    .max_num_mb = 16,
    .num_id_filters = FLEXCAN_RX_FIFO_ID_FILTERS_8,
    .is_rx_fifo_needed = false,
    .flexcanMode = FLEXCAN_NORMAL_MODE,
    .payload = FLEXCAN_PAYLOAD_SIZE_8,
    .bitrate = {
        .propSeg = 7,
        .phaseSeg1 = 4,
        .phaseSeg2 = 1,
        .preDivider = 5,
        .rJumpwidth = 1
    },
    .bitrate_cbt = {
        .propSeg = 7,
        .phaseSeg1 = 4,
        .phaseSeg2 = 1,
        .preDivider = 5,
        .rJumpwidth = 1
    },
    .transfer_type = FLEXCAN_RXFIFO_USING_INTERRUPTS,
    .rxFifoDMAChannel = 0U
};

flexcan_pn_config_t canCom1_PNConfig = {
    .wakeUpTimeout = false,
    .wakeUpMatch = true,
    .numMatches = 1,
    .matchTimeout = 0,
    .filterComb = FLEXCAN_FILTER_ID,
    .idFilter1 = {
        .extendedId = false,
        .remoteFrame = false,
        .id = 1365
    },
    .idFilter2 = {
        .extendedId = true,
        .remoteFrame = true,
        .id = 2046
    },
    .idFilterType = FLEXCAN_FILTER_MATCH_EXACT,
    .payloadFilterType = FLEXCAN_FILTER_MATCH_EXACT,
    .payloadFilter = {
        .dlcLow = 0,
        .dlcHigh = 0,
        .payload1 = { 00000000 },
        .payload2 = { 00000000 }
    }
};

void CAN_TX_RX_Callback(uint8_t instance, flexcan_event_type_t eventType, uint32_t buffIdx, flexcan_state_t *flexcanState)
{
    (void)flexcanState;
    (void)instance;

    switch(eventType)
    {
    case FLEXCAN_EVENT_RX_COMPLETE:
        /*use next circle buffer for the new CAN message receive*/
        FLEXCAN_DRV_Receive(INST_CANCOM1RX_MAILBOX&CAN_RX_Message_Buffer[CAN_RX_BufferIndex%CAN_RX_Buffer_MAX]);
        /* set the receive flag */
        CAN_BufferReceive_Flag = 1;
        break;
    case FLEXCAN_EVENT_RXFIFO_COMPLETE:
        break;
    case FLEXCAN_EVENT_DMA_COMPLETE:
        break;
    case FLEXCAN_EVENT_TX_COMPLETE:
        break;
    case FLEXCAN_EVENT_WAKEUP_TIMEOUT:
        break;
    case FLEXCAN_EVENT_WAKEUP_MATCH:
        // read a message that cause a wake up
        FLEXCAN_DRV_GetWMB(INST_CANCOM1,0,&wmb);
        break;
    default:
        break;
    }
    
}
void can_init(void)
{
    /* CAN 2.0 A/B Buffer configuration */
    /* Set information about the data to be sent
     *  - 1 byte in length
     *  - Standard message ID
     *  - Bit rate switch enabled to use a different bitrate for the data segment
     *  - Flexible data rate enabled
     *  - Use zeros for FD padding
     */
    flexcan_data_info_t dataInfo =
        {
            .data_length = 8,
            .msg_id_type = FLEXCAN_MSG_ID_STD,
            .enable_brs = true,
            .fd_enable = true,
            .fd_padding = 0U};

    FLEXCAN_DRV_Init(INST_CANCOM1&canCom1_State&canCom1_InitConfig0);
    FLEXCAN_DRV_ConfigPN(INST_CANCOM1true&canCom1_PNConfig);
    /*
     * add your CAN transceiver control configuration here if needed
     * for example, toggle the EN/STANDBY pin of TJA1043/44 to enable the transceiver or
     * let it enter normal work mode
     */

    /* Configure TX message buffer with index TX_MSG_ID and TX_MAILBOX*/
    FLEXCAN_DRV_ConfigTxMb(INST_CANCOM1TX_MAILBOX&dataInfoTX_MSG_ID);

    // INT_SYS_InstallHandler(CAN0_ORed_Err_Wakeup_IRQn, &CAN0_ERR_WAKEUP_IRQHandler, (isr_t*) 0);
    // INT_SYS_EnableIRQ(CAN0_ORed_Err_Wakeup_IRQn);
    /* Configure RX message buffer with index RX_MSG_ID and RX_MAILBOX */
    FLEXCAN_DRV_ConfigRxMb(INST_CANCOM1RX_MAILBOX&dataInfoRX_MSG_ID);

//    INT_SYS_EnableIRQ(CAN0_ORed_0_31_MB_IRQn);
    FLEXCAN_DRV_InstallEventCallback(INST_CANCOM1CAN_TX_RX_CallbackNULL);/*install the TX/RX call back*/
    /* Start receiving data in RX_MAILBOX. */
    FLEXCAN_DRV_Receive(INST_CANCOM1RX_MAILBOX&CAN_RX_Message_Buffer[CAN_RX_BufferIndex%CAN_RX_Buffer_MAX]);
}
0 Kudos
Reply
4 Replies

2,022 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi 金生 于,

Please try to observe the RESET_S32K signal of S32K116 by using oscilloscope. Make sure it is high(program is running) when JLink Debug is removed.

I have tried to flash the "Example S32K116 FlexCAN PN STOP S32DS.ARM.2.2" into S32K116EVB, it was able to work when powered by 12V power source(J107 1-2).(Without external J-Link debugger connected)

Best Regards,

Robin

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

2,022 Views
yujinsheng
Contributor I

Could you please help me change a version of 2018R1 SDK 3.0 Flexcan? I will verify it again.

0 Kudos
Reply

2,022 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Would you please try to use S32DS.ARM.2.2? That example is based on it.

Maybe you can try to import "Component Settings to Project" to your S32DS.ARM.2018 project.

Import Component Settings to Project.png

I have "Expert Processor Expert Component Settings", please check the attach file.

Expert Processor Expert Component Settings.png

Best Regards,

Robin

0 Kudos
Reply

2,022 Views
yujinsheng
Contributor I

I confirm that after downloading the program into the chip and disconnecting the downloader, the program can receive the CAN message normally, and then enter the device stop1 through the CAN message command, and then cannot wake up through the CAN message.

0 Kudos
Reply