S32K148的FlexCAN

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
620件の閲覧回数
haha_123456
Contributor I

大家好,在S32K148的demo板子上进行can测试,发现没有can信号输出,代码是和配置参考example的(由于sdk的example编译报错,就自己进行了尝试),主要代码如下:

#define MSG_ID 20u
#define RX_MB_IDX 1U
#define TX_MB_IDX 0U
 
 
volatile int exit_code = 0;
/* User includes */
uint8 dummyData[8] = {1,2,3,4,5,6,7};
 
extern void CAN0_ORED_0_15_MB_IRQHandler(void);
 
/*!
  \brief The main function for the project.
  \details The startup initialization sequence is the following:
 * - startup asm routine
 * - main()
*/
int main(void)
{
    /* Write your code here */
Clock_Ip_Init(&Clock_Ip_aClockConfig[0]);
 
Port_Ci_Port_Ip_Init(NUM_OF_CONFIGURED_PINS_BOARD_InitPins, g_pin_mux_InitConfigArr_BOARD_InitPins);
 
IntCtrl_Ip_EnableIrq(CAN0_ORed_0_15_MB_IRQn);
IntCtrl_Ip_InstallHandler(CAN0_ORed_0_15_MB_IRQn, CAN0_ORED_0_15_MB_IRQHandler, NULL_PTR);
 
Flexcan_Ip_DataInfoType rx_info = {
            .msg_id_type = FLEXCAN_MSG_ID_STD,
            .data_length = 8u,
            .is_polling = TRUE,
            .is_remote = FALSE
    };
 
Flexcan_Ip_MsgBuffType rxData;
FlexCAN_Ip_Init(INST_FLEXCAN_2, &FlexCAN_State0, &FlexCAN_Config0);
FlexCAN_Ip_SetStartMode(INST_FLEXCAN_2);
FlexCAN_Ip_ConfigRxMb(INST_FLEXCAN_2, RX_MB_IDX, &rx_info, MSG_ID);
rx_info.is_polling = FALSE;
FlexCAN_Ip_Send(INST_FLEXCAN_2, TX_MB_IDX, &rx_info, MSG_ID, (uint8 *)&dummyData);
FlexCAN_Ip_Receive(INST_FLEXCAN_2, RX_MB_IDX, &rxData, TRUE);
while(FlexCAN_Ip_GetTransferStatus(INST_FLEXCAN_2, RX_MB_IDX) != FLEXCAN_STATUS_SUCCESS)
{ FlexCAN_Ip_MainFunctionRead(INST_FLEXCAN_2, RX_MB_IDX); }
FlexCAN_Ip_SetStopMode(INST_FLEXCAN_2);
FlexCAN_Ip_Deinit(INST_FLEXCAN_2);
 
    for(;;)
    {
        if(exit_code != 0)
        {
            break;
        }
    }
    return exit_code;
}
引脚配置:haha_123456_0-1724757806026.png
 
can  配置:
haha_123456_0-1724757655423.png

请教一下,为什么会没有信号输出? 或者有没有K148的FlexCAN  成功的example

0 件の賞賛
返信
1 解決策
591件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

on S32K148 EVB a FlexCAN0 using PTE4/PTE5 is connected to the SCB CAN transceiver. Board have to be powered by 12V due to SBC and having CAN transceiver active.
If you use FlexCAN2 with PTE24/PTE25, do you have connected it to an active CAN transceiver as well? In your code you need to enable FlexAN2 ISR as well so change CAN0_ORED_0_15_MB_IRQHandler to CAN2_ORED_0_15_MB_IRQHandler.

Generally check MCR, ECR, ESR1 registers to know status and if any errors are detected.

BR, Petr

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
592件の閲覧回数
PetrS
NXP TechSupport
NXP TechSupport

Hi,

on S32K148 EVB a FlexCAN0 using PTE4/PTE5 is connected to the SCB CAN transceiver. Board have to be powered by 12V due to SBC and having CAN transceiver active.
If you use FlexCAN2 with PTE24/PTE25, do you have connected it to an active CAN transceiver as well? In your code you need to enable FlexAN2 ISR as well so change CAN0_ORED_0_15_MB_IRQHandler to CAN2_ORED_0_15_MB_IRQHandler.

Generally check MCR, ECR, ESR1 registers to know status and if any errors are detected.

BR, Petr

0 件の賞賛
返信
579件の閲覧回数
haha_123456
Contributor I

Thank you!

It work successfull!

0 件の賞賛
返信