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.
已解决! 转到解答。
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
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
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,
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
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
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?
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!