Not Able to Run Simple PIL on RD-K358BMU

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

Not Able to Run Simple PIL on RD-K358BMU

Jump to solution
318 Views
YP_in_XING
Contributor II

Hi,

I follow the video from MATHWORK (Link) to create a simple PIL test with NXP_Support_package_S32K3xx version 1.5.0 on MATLAB 2024a, and the working EVB is RD-K358BMU. The attachment zip file is my implement.

YP_in_XING_0-1721110096968.png

After I create the SIMULINK code, I modified the configuration (both plant and controller), including selecting MCU, modifying UART, MCU, Platform in NXP configuration tool, and modify PIL management, and them run.

Seem the compiler run success with some warning code, but the serial port can not connect so that there are some error message as image (I already checked that my COM number is correct).

YP_in_XING_1-1721111223480.png

I don't know what's wrong here. Please help me. thanks.

 

RD-K358BMU MBDT 

Tags (2)
0 Kudos
Reply
1 Solution
260 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @YP_in_XING ,

Thank you for reporting this issue on our MBDT Community!

Proved out that the issue was caused by a configuration at a deeper layer than just a simple parameter in Simulink.  You did an excellent job when configuring the custom configuration S32CT project, by assigning pins, and configuring the peripherals!

The LPUART1 used by the Debug port on the RD-K358BMU board, uses a different clock source than the other instances of LPUART. This is mentioned in Table 123 in the S32K3xx Reference Manual, Rev. 8, 01/2024, as you may see below:

mariuslucianand_1-1721750407591.png

Now, inside the S32CT, under the Clocks Diagram, you can see that in the MBDT for S32K3 1.5.0, which uses the RTD 4.0.0, the LPUART1_CLOCK is correctly represented, as being driven from the AIPS_PLAT_CLK which runs as 120MHz in this case.

mariuslucianand_2-1721750544783.png

But the Clocks configuration components, translates settings into the Mcu Component of MCAL in S32CT. But, in the Mcu component, under McuModuleConfiguraiton -> McuClock SettingsConfig->McuClockReferencePoint, the actual value for the UART reference point was set to the reference the AIPS_SLOW_CLOCK which is 60MHz. This value, is used inside the Uart component under the Uart Clock Reference, which provides a wrong value to the Uart driver, and this is why, you were not able to communicate over Serial in PIL mode. In other words, the LPUART was configured to work at 120MHz by the Clock tool, but when the baudrate was computed, the configuration was using actually the 60MHz value instead of 120Mhz.

mariuslucianand_3-1721750724964.png

So in your example, what you have to do is to open the external configuration tools, go to Mcu->McuModuleConfiguraiton -> McuClock SettingsConfig->McuClockReferencePoint and change the reference for the UART_CLK to AIPS_PLAT_CLK.

mariuslucianand_0-1721750373347.png

Then make sure that you do these changes for both controller and plant, and you select the right baud rate both in pland and controller Simulink Settings, like in the image below, of course with respect to the actual COM port.

mariuslucianand_4-1721750986444.png

Additional comments regarding your project:

1. When you run PIL, both plant and controller needs to have the exactly same settings when it comes to Simulink Settings and Hardware Target configuration. Because of that, I strongly encourage you to use referenced configurations, which will solved this requirement for you, because the Simulink settings will point to the same configuraiton reference.

2. If you want to do more with the RD-K358BMU board and implement a BMS application, to communicate with the battery cell controllers, than I must make you aware of the fact  that we also have MBDT for BMS 1.1.0, which is an add-on on top of the MBDT for S32K3 1.4.2, and adds support for the MC33772, MC33774 and MC33775 but also MC33665 and MC33664. The MBDT for BMS 1.1.0 is not compatible with the MBDT for S32K3 1.5.0 and works ONLY with the MBDT for S32K3 1.4.2. Also, in the MBDT for S32K3 1.4.2 there is a bug in the RTD 3.0.0 with the LPUART1 clock instance assigment, and the workaround is to have both AIPS_SLOW_CLK and AIPS_PLAT_CLK set to the same value. If you install the MBDT for BMS 1.1.0 and MBDT for S32K3 1.4.2, then you will find already configured examples for the RD-K358BMU board.

 

Hope this helps,

Marius

View solution in original post

Tags (1)
0 Kudos
Reply
1 Reply
261 Views
mariuslucianand
NXP Employee
NXP Employee

Hello @YP_in_XING ,

Thank you for reporting this issue on our MBDT Community!

Proved out that the issue was caused by a configuration at a deeper layer than just a simple parameter in Simulink.  You did an excellent job when configuring the custom configuration S32CT project, by assigning pins, and configuring the peripherals!

The LPUART1 used by the Debug port on the RD-K358BMU board, uses a different clock source than the other instances of LPUART. This is mentioned in Table 123 in the S32K3xx Reference Manual, Rev. 8, 01/2024, as you may see below:

mariuslucianand_1-1721750407591.png

Now, inside the S32CT, under the Clocks Diagram, you can see that in the MBDT for S32K3 1.5.0, which uses the RTD 4.0.0, the LPUART1_CLOCK is correctly represented, as being driven from the AIPS_PLAT_CLK which runs as 120MHz in this case.

mariuslucianand_2-1721750544783.png

But the Clocks configuration components, translates settings into the Mcu Component of MCAL in S32CT. But, in the Mcu component, under McuModuleConfiguraiton -> McuClock SettingsConfig->McuClockReferencePoint, the actual value for the UART reference point was set to the reference the AIPS_SLOW_CLOCK which is 60MHz. This value, is used inside the Uart component under the Uart Clock Reference, which provides a wrong value to the Uart driver, and this is why, you were not able to communicate over Serial in PIL mode. In other words, the LPUART was configured to work at 120MHz by the Clock tool, but when the baudrate was computed, the configuration was using actually the 60MHz value instead of 120Mhz.

mariuslucianand_3-1721750724964.png

So in your example, what you have to do is to open the external configuration tools, go to Mcu->McuModuleConfiguraiton -> McuClock SettingsConfig->McuClockReferencePoint and change the reference for the UART_CLK to AIPS_PLAT_CLK.

mariuslucianand_0-1721750373347.png

Then make sure that you do these changes for both controller and plant, and you select the right baud rate both in pland and controller Simulink Settings, like in the image below, of course with respect to the actual COM port.

mariuslucianand_4-1721750986444.png

Additional comments regarding your project:

1. When you run PIL, both plant and controller needs to have the exactly same settings when it comes to Simulink Settings and Hardware Target configuration. Because of that, I strongly encourage you to use referenced configurations, which will solved this requirement for you, because the Simulink settings will point to the same configuraiton reference.

2. If you want to do more with the RD-K358BMU board and implement a BMS application, to communicate with the battery cell controllers, than I must make you aware of the fact  that we also have MBDT for BMS 1.1.0, which is an add-on on top of the MBDT for S32K3 1.4.2, and adds support for the MC33772, MC33774 and MC33775 but also MC33665 and MC33664. The MBDT for BMS 1.1.0 is not compatible with the MBDT for S32K3 1.5.0 and works ONLY with the MBDT for S32K3 1.4.2. Also, in the MBDT for S32K3 1.4.2 there is a bug in the RTD 3.0.0 with the LPUART1 clock instance assigment, and the workaround is to have both AIPS_SLOW_CLK and AIPS_PLAT_CLK set to the same value. If you install the MBDT for BMS 1.1.0 and MBDT for S32K3 1.4.2, then you will find already configured examples for the RD-K358BMU board.

 

Hope this helps,

Marius

Tags (1)
0 Kudos
Reply