XMC1400 BOOT KIT XMC1400_IIC_Master example

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

cross mob
User14669
Level 1
Level 1
hello,

I am trying to run the XMC1400_IIC_Master example. I have a 2kOhms pull-up resitance on SCL and SDA.
The problem I have is that the SCL stay at Vdd and SDA shortly goes to GND and it never stops.
In debug it stay stick to the "while (XMC_USIC_CH_GetTransmitBufferStatus(channel) == XMC_USIC_CH_TBUF_STATUS_BUSY)" line in the" void XMC_I2C_CH_MasterStart" function in xmc_i2c.c
I was able to run the BlinkyLed_MCAN and XMC1400_SPI_Loopback before without problems.
I attach file a screenshot of the osciloscope of P3.0 (SCL blue) and P3.1 (SDA red)

is there anything to do in addition to make this example working?

thank you and best regards
3280.attach
0 Likes
5 Replies
DRubeša
Employee
Employee
First solution authored First like received
Hi,

may you please point me where have you find mentioned example ("XMC1400_IIC_Master" example)? I would like to check the pin configuration in that example.

Best regards,
Deni
0 Likes
User14669
Level 1
Level 1
thank you for your answer,

I have download the example from:
https://www.infineon.com/cms/en/product/evaluation-boards/kit_xmc14_boot_001/

then in "application Examples" section

best regards
0 Likes
DRubeša
Employee
Employee
First solution authored First like received
Hi,

I´ve took a look at that example and I´ve noticed the XMC1400 Boot kit should be connect to a White LED board to test the I2C functionality. Are you using that board with the assembled temperature sensor or to which device are you connecting? For example, in the datasheet of mentioned sensor it´s suggested to use 10kOhm pull up resistors. I´ve run the example and it´s working as expect in my case. I agree that your oscilloscope snapshot doesn´t looks correctly, so maybe try experimenting with a different resistor value (the values should be chosen based on the bus capacitance and used I2C baudrate, so your requirements may vary). Also, in comparison with the given example I would suggest to define for both pins to have a HIGH output level as an initial state, so the pins configuration structure should look something like this:

const XMC_GPIO_CONFIG_t I2C_MASTER_0_sda_pin_config   =
{
.mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
};
const XMC_GPIO_CONFIG_t I2C_MASTER_0_scl_pin_config =
{
.mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
};


Let me know these additional information (which device are you connecting too and are you using the same pins as in the example that you mentioned) and did the different resistor value or changing of the pin configuration help with the issue.

Best regards,
Deni
0 Likes
User14669
Level 1
Level 1
thank you for your answer,

I am trying to communicate with a magnetic field sensor TLV493V from Infineon.

In the code, I have just modify the line:
#define TEMP_SENS_ADDR (0xBC)

I have also try with 0x3E as address (the 2 possible adress for the sensor depending on SDA at start.

I have try with pull-up from 1Kohms to 10kohms and frequency from 100K to 400K. I have add the ".output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH" line in the pin config.

unfortunatly the signal stay the same.

Here is the full code if needed:
/*********************************************************************************************************************
* HEADER FILES
********************************************************************************************************************/
#include
#include

/*********************************************************************************************************************
* MACROS
*********************************************************************************************************************/
#define I2C_CH_NUM XMC_I2C1_CH1
#define TEMP_SENS_ADDR (0xBC)//3E
#define SDA_PIN P3_1
#define SCL_PIN P3_0
#define LED P4_0

/*********************************************************************************************************************
* DATA STRUCTURES
*********************************************************************************************************************/
/* IIC configuration */
XMC_I2C_CH_CONFIG_t i2c_cfg =
{
.baudrate = 200000U,
};

/* IIC SDA and SCL Pins */
XMC_GPIO_CONFIG_t i2c_sda =
{
.mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT2,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
};

XMC_GPIO_CONFIG_t i2c_scl =
{
.mode = XMC_GPIO_MODE_OUTPUT_OPEN_DRAIN_ALT3,
.output_level = XMC_GPIO_OUTPUT_LEVEL_HIGH,
};

/* GPIO LED pin configuration */
XMC_GPIO_CONFIG_t LED_pin_config =
{
.mode = XMC_GPIO_MODE_OUTPUT_PUSH_PULL,
.output_level= 1U
};

/*********************************************************************************************************************
* GLOBAL VARIABLES
*********************************************************************************************************************/
uint16_t Temperature = 0x0000;

/*********************************************************************************************************************
* LOCAL ROUTINES
*********************************************************************************************************************/
void Read_Temperature (void)
{
uint16_t DataReceived = 0x0000;

Temperature = -1;

XMC_I2C_CH_MasterStart(I2C_CH_NUM, TEMP_SENS_ADDR, XMC_I2C_CH_CMD_READ);
while((XMC_I2C_CH_GetStatusFlag(I2C_CH_NUM) & XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED) == 0U)
{
/* wait for ACK */
}
XMC_I2C_CH_ClearStatusFlag(I2C_CH_NUM, XMC_I2C_CH_STATUS_FLAG_ACK_RECEIVED);


XMC_I2C_CH_MasterReceiveAck(I2C_CH_NUM);
while((XMC_I2C_CH_GetStatusFlag(I2C_CH_NUM) & (XMC_I2C_CH_STATUS_FLAG_RECEIVE_INDICATION |
XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION)) == 0U)
{
/* wait for ACK */
}
XMC_I2C_CH_ClearStatusFlag(I2C_CH_NUM, XMC_I2C_CH_STATUS_FLAG_RECEIVE_INDICATION |
XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);

XMC_I2C_CH_MasterReceiveNack(I2C_CH_NUM);
while((XMC_I2C_CH_GetStatusFlag(I2C_CH_NUM) & (XMC_I2C_CH_STATUS_FLAG_RECEIVE_INDICATION |
XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION)) == 0U)
{
/* wait for ACK */
}
XMC_I2C_CH_ClearStatusFlag(I2C_CH_NUM, XMC_I2C_CH_STATUS_FLAG_RECEIVE_INDICATION |
XMC_I2C_CH_STATUS_FLAG_ALTERNATIVE_RECEIVE_INDICATION);

XMC_I2C_CH_MasterStop(I2C_CH_NUM);

DataReceived = XMC_I2C_CH_GetReceivedData(I2C_CH_NUM);


// mask out the high byte form FIFO and cast to byte
Temperature = (DataReceived & 0x00FF);
//toggle LED
XMC_GPIO_ToggleOutput(LED);
}

void timing_delay(void)
{
uint32_t d;
for(d=0; d<1000000;d++)
{;}
}

/*********************************************************************************************************************
* INITIALIZATION & FUNCTION IMPLEMENTATION
*********************************************************************************************************************/
int main(void)
{
/* Configure IIC channel */
XMC_I2C_CH_Init(I2C_CH_NUM, &i2c_cfg);
/* Configure input multiplexors */
XMC_I2C_CH_SetInputSource(I2C_CH_NUM, XMC_I2C_CH_INPUT_SDA, 5);
XMC_I2C_CH_SetInputSource(I2C_CH_NUM, XMC_I2C_CH_INPUT_SCL, 3);
/* Start IIC channel */
XMC_I2C_CH_Start(I2C_CH_NUM);

/* Initialize GPIO */
XMC_GPIO_Init(SCL_PIN, &i2c_scl);
XMC_GPIO_Init(SDA_PIN, &i2c_sda);
XMC_GPIO_Init(LED, &LED_pin_config);

while(1)
{
Read_Temperature();
/* Insert a timing delay to make LED toggling visible, otherwise the delay is not needed */
timing_delay();
}
return 0;
}


thankyou and best regards
0 Likes
User14669
Level 1
Level 1
At the end, it is a problem related to the osciloscop to measure the signal of the SCL and SDA line. At the end, the example works.

thanks a lot for your support
0 Likes