How to Build the FlexCAN Example project for S32R45 on M7 core?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to Build the FlexCAN Example project for S32R45 on M7 core?

跳至解决方案
5,088 次查看
A-Jay
Contributor III
  • I used the S32DS to create a new FlexCAN_Ip_Example_S32R45_M7 project and I change its FlexCAN operation modes for Normal mode or user mode in Drivers->FlexCAN_1->FlexCAN configurations page.But I don't know how to make it work.

  • How to set its clock?
  • how to set CAN Baud Rate 500KBaud in FlexCAN configurations page ?
  • And I don't know if the main.c file should be changed?
  • I hop you can help me! Or Make a new Example for FlexCAN operation modes is Normal mode or user mode.Or others?
  • Thanks!
标签 (1)
标记 (2)
0 项奖励
回复
1 解答
5,066 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the example is configured in Loopback mode, so can be useful to test sending/receiving operation, interrupts, etc, but for sure no communication with external nodes is functional. To allow this some modification have to be done, mainly adding pins used to connect with CAN transceiver, proper CAN bit timing, etc. 
1. CAN protocol clock is set in Clock config tool. By default FIRC is used (48MHz), so this can be kept
2. In flexcan component use below setting for 500 kbit/s assuming 48MHz PE clock, also change operational mode 

PetrS_0-1669293506974.png

3. you should add used CAN TX /RX pins in Pins config tool, based on your HW.
4. Add Siul2_port driver in Peripherals config tool and Update code.
5. Use attached main.c

I do not have any board, so did not test it, but hope it helps little bit.

BR, Petr

在原帖中查看解决方案

7 回复数
3,846 次查看
JonAnder_Amante
Contributor I

Hi Sir,  I am trying to run the Flexcan programme but I have different errors in the board MR-CANHUBK344, I want send information from Can_0 and receive to Can_1. Firstly, when I realize the debugging I can`t receive the information in the array of rxdata. I checked the program with the mode of loopback and it`s correct but when I debug the program in normal mode I had problems. I have the same main as you and I think that the configuration of pins are well. About pins configuration I have configurated PTA6 as CAN0_rx, PTA7 as CAN0_tx, PTA22 as CAN1_rx and PTA23 as CAN1_tx. I send you mi program because I dont`t know what is my error.  Thank you for all, 

0 项奖励
回复
4,119 次查看
ArifJ
Contributor I

Can anyone explain what does that RX_MB_IDX AND TX_MB_IDX and what FlexCAN Instance defines here is it Indicating FlexCAN 0 ? 

0 项奖励
回复
5,067 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

the example is configured in Loopback mode, so can be useful to test sending/receiving operation, interrupts, etc, but for sure no communication with external nodes is functional. To allow this some modification have to be done, mainly adding pins used to connect with CAN transceiver, proper CAN bit timing, etc. 
1. CAN protocol clock is set in Clock config tool. By default FIRC is used (48MHz), so this can be kept
2. In flexcan component use below setting for 500 kbit/s assuming 48MHz PE clock, also change operational mode 

PetrS_0-1669293506974.png

3. you should add used CAN TX /RX pins in Pins config tool, based on your HW.
4. Add Siul2_port driver in Peripherals config tool and Update code.
5. Use attached main.c

I do not have any board, so did not test it, but hope it helps little bit.

BR, Petr

5,060 次查看
A-Jay
Contributor III

Thank you for your reply!

I tried it with main.c according to your method, and there was no problem in sending, but there was a problem in receiving CAN data. The result of "FlexCAN_Ip_GetTransferStatus(FLEXCAN_INST,RX_MB_IDX)" was always FLEXCAN_STATUS_BUSY. When I changed the value of RX_MB_IDX to 0U, the program could keep sending data, but still couldn't receive it. Running in breakpoint mode, rxData never has data.

  • How do I send the standard frame CAN data from the PC for the program to receive?

    AJay_0-1669351097432.png

     

0 项奖励
回复
5,047 次查看
PetrS
NXP TechSupport
NXP TechSupport

Hi,

you will need some USB CAN adapter, there are many on the web to be purchased.
Or use some other board for sending messages. Or other CAN modules on your board.

BR, Petr

0 项奖励
回复
5,045 次查看
A-Jay
Contributor III

Thanks for your reply!

I have solved this problem, the cause of the problem is due to the MSG_ID field, which set the send and receive frame ID can only be 0x14(20U). After changing the ID of the sent data to 0x14 on the PC side, the program can receive the CAN data.

Thank you very much for your answer!

 

3,590 次查看
shuo41
Contributor III

Sir,can you send your project to me?I wan test FlexCAN through mcu and can analyser,but it was not successful.

0 项奖励
回复