Hi NXP Team,
I'm using S32K358-EVB on MBDT to try I2C module.
I've seen the async example and i tried to replicate the configuration with my project using LPI2C0 as master that sends 1 byte. looking with the oscilloscope i can't see any SCL or SDA signal going out from the respective pins...
What i'm my missing in this configuration? how could i solve this problem?
I attach the prj
Thanks,
Simon
已解决! 转到解答。
Hello @simon98,
From what I found in the datasheet of the ASM330LHB accelerometer, in the table with I2C slave timing values it says that the SCL clock low time and the SCL clock high time must have a minimum value of 4.7 us and 4.0 us respectively. So the accelerometer can also work with higher values of these parameters.
Regarding the other question, the Lpi2c Module Clock Frequency is configured at /Mcu/Mcu/McuModuleConfiguration/McuClockSettingConfig_0/I2C_CLK in your project, so it is equal to 60 MHz and the I2C Master Prescaler does not change the peripheral clock source.
The I2C Master Prescaler is indeed used for calculating the I2C Baud Rate, along with the I2c Clock High Period, I2c Clock Low Period, and I2c Glitch Filter SCL, as you can see in the image below from RTD_I2C_UM.pdf.
For example, using the configuration parameters in the image below will result in a value of 89286 for the I2c Baud Rate (CLKLO = 20, CLKHI = 20, PRESCALER = 4 (DIV_16), FILTSCL = 0).
For more details about the I2C driver and its parameters, you can check the RTD I2C user manual located in S32K3_RTD\SW32K3_S32M27x_RTD_R21-11_4.0.0_P19\eclipse\plugins\I2c_TS_T40D34M40I0R0. You can also check chapter 71 of the Reference Manual located in mbdtbx_s32k3\help\docs for further explanations.
Hope this helps,
Cristina
Hello @simon98,
Thank you for using the Model-Based Design Toolbox for S32K3. First, a few notes about the S32CT configuration. I noticed that the Direction of the LPI2C0_SCL pin is set to Output in your configuration project; both I2C pins should have the Direction set to Input/Output, as you can see in the image below.
Then, for configuring I2cChannel_0, you can try the settings in the image below. The parameters are modified to obtain the I2c Baud Rate from the default configuration projects for the hardware parts that have the I2C component configured.
Please note that the signal lines used for I2C transmission require external 2k Ohm pull-up resistors between SDA and VDD and SCL and VDD. As I noticed in the SCH-54870 schematic of the XS32K3X8EVB-Q289, the pins configured in your mex file (PTF20 and PTF21) are not connected to a VDD via resistors, so you need external resistors for I2C communication to work. Alternatively, you can use the PTC6 and PTC7 pins which can be routed to LPI2C1_SDA and LPI2C1_SCL and are connected to VDD_IO via 10k Ohm pull-up resistors, as you can see in the image below. To be able to use them, you just need to configure the LPI2C1 pins and select the LPI2C_1 peripheral in the I2cChannel_0 channel. If you have a hardware board with a different schematic version, please check if these observations still apply to your case.
Regarding the application you sent, I have a few questions. What device are you trying to interface with? I noticed that the Slave address given as an input for the I2c_AsyncTransmit block in your model is set to 50. Is this the address of your slave device?
To give you a little background, here are some details about the MBDT implementation of the I2C component. The request structure required in the I2c_SyncTransmit and I2c_AsyncTransmit functions has the following parameters:
The Data Direction parameter can be chosen from the drop-down menu inside the block mask. The 10 Bits Slave Address Size and High Speed Mode parameters can be selected from the checkboxes inside the block mask.
The Slave Address, Repeated Start, Expect Nack, Data Tx (for the Send direction), Buffer Size (for the Receive direction) parameters are expected as inputs to the block, while Data Rx (for the Receive direction) will be an output to the block.
Let me know if these suggestions work or if you need further help.
Best regards,
Cristina
Hi @CristinaB
My project was to understand how I2C works with the S32K358 and how to configure it in S32CT, so i've choosen a random address of 50 (as the example)
I've found out also that the problem of transmission was the absence of the pull-up resistors on the pins configured.
So thanks for this explanation!
I've an other question for you:
I'm trying to make a communication with ASM330LHB accelerometer in another project and, looking on its datasheet, it needs some specific parameters value to work, for example clock high/low time....
I was wondering, if i have a clock source of 60MHz for LPI2C0 and i want to set these two parameters on S32CT around 4/5 us, how could i do? if i change the I2C Master Prescaler does it change the LPI2C0 clock source or it's only used for I2C Baud Rate calculation?
thanks
Simon
Hello @simon98,
From what I found in the datasheet of the ASM330LHB accelerometer, in the table with I2C slave timing values it says that the SCL clock low time and the SCL clock high time must have a minimum value of 4.7 us and 4.0 us respectively. So the accelerometer can also work with higher values of these parameters.
Regarding the other question, the Lpi2c Module Clock Frequency is configured at /Mcu/Mcu/McuModuleConfiguration/McuClockSettingConfig_0/I2C_CLK in your project, so it is equal to 60 MHz and the I2C Master Prescaler does not change the peripheral clock source.
The I2C Master Prescaler is indeed used for calculating the I2C Baud Rate, along with the I2c Clock High Period, I2c Clock Low Period, and I2c Glitch Filter SCL, as you can see in the image below from RTD_I2C_UM.pdf.
For example, using the configuration parameters in the image below will result in a value of 89286 for the I2c Baud Rate (CLKLO = 20, CLKHI = 20, PRESCALER = 4 (DIV_16), FILTSCL = 0).
For more details about the I2C driver and its parameters, you can check the RTD I2C user manual located in S32K3_RTD\SW32K3_S32M27x_RTD_R21-11_4.0.0_P19\eclipse\plugins\I2c_TS_T40D34M40I0R0. You can also check chapter 71 of the Reference Manual located in mbdtbx_s32k3\help\docs for further explanations.
Hope this helps,
Cristina