Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

AURIX™ Forum Discussions

rajeshkumar
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

Hi,

I am using Aurix TC397XX controller and checking the I2C functionalities with I2C end device. In our case RTC (read time clock) I2C endpoint is connected on I2C bus 1. I have taken the I2C code example from Aurix "I2C_Read_Ext_Device_1_KIT_TC397_TFT" application code.

The I2C initialization part was OK, there were no errors from the API during the initialization of the code. The baud-rate was configured as 400KHz (RTC also supports the same master clock). But when I do write or read operation using I2C APIs, the I2C Master clock is not driving from Aurix SCL pins and I couldn't read/write any data from the RTC chip. We confirmed this by probing the SCL lines using Oscilloscope.

Pin mux configuration are done properly.

What might be the issue of the generating the I2C master clock?

 

<Init Code Start>

void init_Rtc_I2C_module(void)
{
/* Initialize module */
IfxI2c_I2c_Config i2cConfig; /* Create configuration structure */

//Disable Interrupts
boolean interruptState = IfxCpu_disableInterrupts();

IfxI2c_I2c_initConfig(&i2cConfig, &MODULE_I2C1); /* Fill structure with default values and Module
address */
/* I2c pin configuration */
const IfxI2c_Pins RTC_PINS =
{
&RTC_SCL_PIN, /* SCL port pin */
&RTC_SDA_PIN, /* SDA port pin */
IfxPort_PadDriver_ttlSpeed1 /* Pad driver mode */
};
i2cConfig.pins = &RTC_PINS; /* Configure port pins */
i2cConfig.baudrate = I2C_BAUDRATE; /* Configure baud rate with 400kHz */

IfxI2c_I2c_initModule(&g_i2cRtcHandle, &i2cConfig); /* Initialize module */

/* Initialize device */
IfxI2c_I2c_deviceConfig i2cDeviceConfig; /* Create device configuration */
IfxI2c_I2c_initDeviceConfig(&i2cDeviceConfig, &g_i2cRtcHandle); /* Fill structure with default values and I2C
Handler */
/* Because it is 7 bit long and bit 0 is R/W bit, the device address has to be shifted by 1 */
i2cDeviceConfig.deviceAddress = RTC_WR_SLV_ADDR << 1;
IfxI2c_I2c_initDevice(&g_i2cDevRtc, &i2cDeviceConfig); /* Initialize the I2C device handle */

//re-enable interrupts
IfxCpu_restoreInterrupts(interruptState);

}

<Init Code End>

 

 

Thanks,

Rajesh

0 Likes
7 Replies
KB
Moderator
Moderator
Moderator
10 solutions authored 50 sign-ins 25 replies posted

Hello rajeshkumar,

If have some queries:

1. What is the state of SCL and SDA pin ? Is it always HIGH or LOW ?

2. Have tried I2C_Read_Ext_Device_1_KIT_TC397_TFT example without any of your modifications and observed waveform on pin SDA(Pin 15.5) and SCL (Pin 15.4)? 

3.  If step 2 works can you verify if your modified code can drive above SCL and SDA pins ? (you need to modify your code's I2C channel to 0 and SDA/SCL to pin 15.5 and 15.4 respectively).

 

Regards,

KB

0 Likes
rajeshkumar
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

Hi KB,

Please find my answer to questions inline.

1. What is the state of SCL and SDA pin ? Is it always HIGH or LOW ?

>> Both SCL and SDA pins are always high. We have harware pull up for this lines.

2. Have tried I2C_Read_Ext_Device_1_KIT_TC397_TFT example without any of your modifications and observed waveform on pin SDA(Pin 15.5) and SCL (Pin 15.4)? 

>> I have tried with I2C_Read_Ext_Device_1_KIT_TC397_TFT example, but even the write and read operations not working. Only I modiefied in this example code is Pin details (P11.13, P11.14) based on our target pin mapping.

3.  If step 2 works can you verify if your modified code can drive above SCL and SDA pins ? (you need to modify your code's I2C channel to 0 and SDA/SCL to pin 15.5 and 15.4 respectively).

>> We are using I2C bus 1, where pins P11.13 and P11.14 are used in our board.

Thanks,

Rajesh

0 Likes
MoD
Employee
Employee
250 sign-ins 25 likes received 50 solutions authored

What is the definition of RTC_SCL_PIN and RTC_SDA_PIN?

0 Likes
rajeshkumar
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

Definition of RTC_SCL and SDS Pins:

#define RTC_SCL_PIN IfxI2c1_SCL_P11_14_INOUT       /* SCL PIN */
#define RTC_SDA_PIN IfxI2c1_SDA_P11_13_INOUT      /* SDA PIN

 

Herewith, I have attached my sample code for your reference.

0 Likes
KB
Moderator
Moderator
Moderator
10 solutions authored 50 sign-ins 25 replies posted

Hi Rajesh,

Is your program able to come out of the loop "while(IfxI2c_I2c_write(&g_i2cDevRtc, &i2cTxBuffer[0], LENGTH_OF_ADDRESS) == IfxI2c_I2c_Status_nak)"  ?

If not could share screenshot of the register PIRQSS ?

Also can you configure and check if changing pad driver mode to IfxPort_PadDriver_ttlSpeed1 works?

Thank You.
 

0 Likes
rajeshkumar
Level 2
Level 2
10 sign-ins 5 replies posted 5 sign-ins

Hi KB,

Pls find my reply inline

Is your program able to come out of the loop "while(IfxI2c_I2c_write(&g_i2cDevRtc, &i2cTxBuffer[0], LENGTH_OF_ADDRESS) == IfxI2c_I2c_Status_nak)"  ?

>> Yes, the execution is coming out of the while loop. The return value of IfxI2c_I2c_write API is IfxI2c_I2c_Status_ok.

If not could share screenshot of the register PIRQSS ?

>> PIRQSS.U = 0

Also can you configure and check if changing pad driver mode to IfxPort_PadDriver_ttlSpeed1 works?

>> I had tried with TTL SPEED-1 pad driver option also, but even I see the same issue.

 

Thanks,

Rajesh

0 Likes
KB
Moderator
Moderator
Moderator
10 solutions authored 50 sign-ins 25 replies posted

 

Hi Rajesh,

Everything seems to be fine, since you say your are getting IfxI2c_I2c_Status_ok.

But still you could do some testing and share the results:

1. Try toggling the  SCLK and SDA pins by using respective PORT->OMR register and see if there any level change on these pins.
2. Change the baud rate to lower value say 200k and check if there is any change in behavior.
3. Change the mode to IfxPort_Mode_outputOpenDrainAlt6 if its set to IfxPort_Mode_outputOpenDrainGeneral.

KB_0-1651149670211.png


4. Also could you share the clock frequencies: Frequency of SPB(fSPB = ?) and Frequency of I2C(fI2C = ?) ?

5. Also share the log of variable: i2cDevice.

KB_1-1651150017309.png

6. Also can you make sure that the variables used by I2C to send data are word-aligned .

 

Thank you.

0 Likes