Configuring 4 CAN. S32K396

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

Configuring 4 CAN. S32K396

跳至解决方案
2,551 次查看
MaMM
Contributor III

Hello.

I have a working example with the CAN0 port, sending and receiving messages (standard and extended), via interrupts. Now I’m defining the CAN1, and when configuring it in Tresos (with no errors in the configuration), when downloading it to the evaluation board, the application doesn’t start. Maybe I’m missing something to activate, but I haven’t found what it is. Is there any example in Tresos for multiple CAN ports configured and working for the S32k396?"

Miguel.

0 项奖励
回复
1 解答
2,488 次查看
Adrian_Gherca
NXP Employee
NXP Employee

If you have the possibility, in S32DesignStudio, add a breakpoint in the HardFault_Handler function in exceptions.c :

Excepion_HardFault.png

I suspect that the MCU clock configuration might be incorrect.
Please have a look at the article I previously mentioned:
Communicating over the CAN Bus  .
Chapter 2, CAN configuration, it is very important. Look at subchapter 2.5, Clocks Configuration.

 

在原帖中查看解决方案

0 项奖励
回复
9 回复数
2,515 次查看
Adrian_Gherca
NXP Employee
NXP Employee

Hello,

Please make sure that the transceiver corresponding to CAN1 is properly activated. This is done in the Initialize Function of the Simulink model:
CAN_InitializeFunction.png

An example that uses CAN0 and CAN1 instances of the FLEXCAN peripheral can be found in the MBDT_S32K3xx toolbox: src\S32K3_Examples\MR-CANHUBK344\mrcanhubk344_can_ebt .

For more info please have a look this article: Communicating over the CAN Bus

0 项奖励
回复
2,503 次查看
MaMM
Contributor III

Hello Adrian.

Thanks for the answer. The problem I'm having is that the processor doesn't start. I'm using the S32K396-BGA-DC1 Evaluation Board, and the CAN0 is working fine. However, when I configure CAN1, the processor doesn't start. (I have an LED with a flip-flop to ensure the SW is up and running). I have activated CAN1 in the configuration, through an interrupt, and enabled the FLEXCAN1 interrupts. Looking at the example you mentioned, I don't see any differences between my configuration and the example, but I may be missing something. I have also included the CAN_Set_Control_Mode block in Simulink, with the CAN_CS_STARTED function, pointing to CAN1...CAN config capture 1.pngCAN config capture 2.pngCAN config capture 3.pngCAN config capture 4.png

 

Any idea?

Thanks in advance.

标记 (1)
0 项奖励
回复
2,489 次查看
Adrian_Gherca
NXP Employee
NXP Employee

If you have the possibility, in S32DesignStudio, add a breakpoint in the HardFault_Handler function in exceptions.c :

Excepion_HardFault.png

I suspect that the MCU clock configuration might be incorrect.
Please have a look at the article I previously mentioned:
Communicating over the CAN Bus  .
Chapter 2, CAN configuration, it is very important. Look at subchapter 2.5, Clocks Configuration.

 

0 项奖励
回复
2,439 次查看
MaMM
Contributor III

Dear Adrian.

Thanks for the answer. I have activated the FLEXCAN_1 into MCUPeripehral (see image), and now the MCU works. The issue now is that I'm trying to link the new Flexcan to pins 175 and 174 of the board, but there are no CAN messages. My question to you is: The "PortPin ID" and "PortPin" must follow any type of equation to calculate, as de DIO must follow? For example, the DIO must follow the equation:

Microcontroller pin = DioChannel Id + Dio Port Id * 16

Maybe I'm not assigning the channel correctly?

0 项奖励
回复
2,401 次查看
Irina_Costachescu
NXP Employee
NXP Employee

Hi @MaMM 

The formula for computing the Dio Channel Id and Port Pin Id, based on the MSCR of the pins that you would like to use is correct, and this should be reflected inside the configurations of the Dio and Port components.

I have taken a look into the S32K396-BGA-DC1 EVB schematics, and noticed that on this board there is only one CAN transceiver, connected to CAN0 instance of the peripheral (CAN0_RX and CAN0_TX pins). For being able to send messages on the bus using the CAN1 instance, the CAN1_TX and CAN1_RX signals must be connected to a transceiver as well. For this, you would need to use an external transceiver, and make sure that it is initialized properly inside the Simulink application. 

Is your hardware setup consisting only of the S32K396-BGA-DC1 EVB, or does it also integrate the S32X-MB (I/O extension board compatible with the evaluation boards for the S32K39/37 microcontrollers) ?

The reason why I am asking is because the S32X-MB provides additional functionality and access to I/O and peripherals, and perhaps we could try and use one of its transceivers for furtherly routing the CAN1 signals to their appropriate connection to enable CAN communication on this peripheral instance. 

Thank you,

Irina

0 项奖励
回复
2,381 次查看
MaMM
Contributor III

Hi Irina.

Before anything else, it might be helpful to mention the setup I have. Currently, I have the S32K396-BGA-DC1 board connected to the S32X-MB, where there are 4 DB9 connectors to test up to 4 CAN ports simultaneously. Additionally, I have a PCAN_USB connected to the CAN0 port of the board (S32K396-BGA-DC1), and it works perfectly.

On the S32X-MB board, each of them has a transceiver, as you mentioned, so that communication can be established. As it comes connected from the factory, I have programmed CAN1 on pins 175 (CAN1RX) and 174 (CAN1TX), but I do not see communication through the DB9 port.

Do you have any example of activating multiple CANs with the configuration of both cards?

标记 (1)
0 项奖励
回复
2,371 次查看
Irina_Costachescu
NXP Employee
NXP Employee

Hi @MaMM 

As I can see from the MB schematics, CAN1_H and CAN1_L are connected to a TJA1448AT transceiver. Based on the transceiver datasheet, its operating mode is set to normal by the hardware routing of the STB1/STB2 pins to the ground - hence, there is no need to perform any initialization of this device inside the Simulink application model. 

The transceiver input is represented by the pins PJ_GPIO[146] and PJ_GPIO[147], routed via the J13 jumper. If the jumper is connected, the signals should be correctly passed to the TJA1448AT, and the CAN High and Low signals outputted on the J15 DB9 connector.

Can you please check if, when connecting the MB to the S32K396-BGA-DC1 board, PJ_GPIO[146] and PJ_GPIO[147] are matching the pins with MSCR 175 (PTF15) and 174 (PTF14)? 

From what I can see, on the MB, PJ_GPIO[146] and PJ_GPIO[147] are placed on the J55D connector (lines 185 and 186). In the BGA-DC1 schematic, on the same J55D connector, there are different pins on the 185 and 186 signal lines, more specifically PTD30 and PTD31.

Hence, my assumption would be that inside your configuration project, PTD30 and PTD31 should be configured as CAN1_TX and CAN1_RX functionality, as, based on the hardware connections that I have seen, the signals routed to PTF15 and PTF14 are not reaching the transceiver.

Could you please check the details above and let us know if this is also the hardware setup on which you are deploying your application?

Thank you,

Irina

 

2,311 次查看
MaMM
Contributor III

Hi Irina

Thanks for your message. As you pointed out, the ports I selected don't reach the transceiver, so no messages are in the bus. I have modified the pins as you indicated and now I see the message thorugh the PORT1, so thanks for the help. Now, I need to configure the other three ports to use the 4 DB9 present on the board.

Now, in order to continue testing and for example:

For testing CAN2, the pins are (PTD18 and PTD19), which are connected to J55B(87) and J55E(251), respectively. Then, in the MB, they correspond to PD_GPIO[50], PORTD(3) and PM_GPIO[200], PORTM(9). I suppose than connecting these pins (PORTD[3] and PORTM[9]) to J18 2 and 4 (before the transceiver), I should read messages. Is this procedure ok?

Thanks in advance!

0 项奖励
回复
2,260 次查看
MaMM
Contributor III

Hi.

My previous assumption is correct. By making that wiring, it is possible to see CAN communication on the DB9. The only thing is that I am using a template that I am modifying, and until I "generated the project," the configuration had not been updated from Simulink. After generating it in Tresos and compiling from Simulink, it works perfectly. I am closing the thread. Thanks.

标记 (1)
0 项奖励
回复