infineon4engineers Facebook

infineon@google+ Google+

infineon@linkedin linkedin

infineon4engi@twitter twitter

infineon@youtube youtube

+ Reply to Thread
Results 1 to 6 of 6

Thread: XMC1400 BOOT KIT XMC1400_IIC_Master example

  1. #1
    Beginner Beginner pierre jo is on a distinguished road
    Join Date
    Mar 2018
    Location
    Holzkirchen
    Posts
    5
    Points
    65

    XMC1400 BOOT KIT XMC1400_IIC_Master example

    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
    Click image for larger version

Name:	problem_xmc1400_i2c.png
Views:	3
Size:	64.3 KB
ID:	3636

  2. #2
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    191
    Points
    2882.5
    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
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  3. #3
    Beginner Beginner pierre jo is on a distinguished road
    Join Date
    Mar 2018
    Location
    Holzkirchen
    Posts
    5
    Points
    65
    thank you for your answer,

    I have download the example from:
    https://www.infineon.com/cms/en/prod...mc14_boot_001/

    then in "application Examples" section

    best regards

  4. #4
    Advanced Advanced
    Infineon Employee
    Infineon Employee
    DRubeša will become famous soon enough
    Join Date
    Jul 2016
    Location
    München
    Posts
    191
    Points
    2882.5
    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:

    Code:
    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
    The views expressed here are my personal opinions, have not been reviewed or authorized by Infineon and do not necessarily represent the views of Infineon.

  5. #5
    Beginner Beginner pierre jo is on a distinguished road
    Join Date
    Mar 2018
    Location
    Holzkirchen
    Posts
    5
    Points
    65
    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 <xmc_i2c.h>
    #include <xmc_gpio.h>

    /************************************************** ************************************************** *****************
    * 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_INDICAT ION)) == 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_INDICAT ION);

    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_INDICAT ION)) == 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_INDICAT ION);

    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

  6. #6
    Beginner Beginner pierre jo is on a distinguished road
    Join Date
    Mar 2018
    Location
    Holzkirchen
    Posts
    5
    Points
    65
    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

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.