How to use I2C Application in XMC1100, DAVE4

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

cross mob
User21523
Level 1
Level 1
Welcome! First question asked
hi,

I have KIT_XMC11_BOOT_001 and try I2C using temperature sensor.
At first I would like to check I2C application's method is working correctly.

But it doesn't work, i mean when probe SDA, SCL there is no signal output.
and fall in loop line 44.

what i missed?


/*
* main.c
*
* Created on: 2021 Sep 29 14:27:58
* Author: A
*/




#include //Declarations from DAVE Code Generation (includes SFR declaration)

/**

* @brief main() - Application entry point
*
* Details of function

* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/
uint8_t buffer[1] = {0x0B};
int main(void)
{
DAVE_STATUS_t status;

status = DAVE_Init(); /* Initialization of DAVE APPs */

if(status != DAVE_STATUS_SUCCESS)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");

while(1U)
{

}
}

/* Placeholder for user application code. The while loop below can be replaced with user application code. */
while(1U)
{
I2C_MASTER_Transmit(&I2C_MASTER_0, true, 0x90, buffer, 1, true);
while(I2C_MASTER_IsTxBusy(&I2C_MASTER_0)) {};
}
}
0 Likes
2 Replies
Aashita_R
Moderator
Moderator
Moderator
50 likes received 100 solutions authored 250 replies posted
Hi @marq86,

Assuming that the code which you have shared is the entire main.c file here, there are a few points you need to check before I2C can be made to work -
1. Please try configuring the SDA and SCL pins as per the required I2C configuration such as their mode and output strength.
2. You need to set the Baud-rate for I2C transfer.
3. Select the appropriate input source channels of the USIC module, which will be configured as I2C.

We regret to inform that we presently do not have I2C code example, devised for XMC 1100 device but I have shared an image below from the xmc-4500 I2C_TRANSER code example which is a part of xmc-library. This image will help you understand the flow of code for the working of I2C.
5475.attach

Please go through this code example and the image so as to try at your end and let us know in case of any query.

Best Regards,
Aashita
0 Likes
pentleman
Level 1
Level 1
5 replies posted First solution authored First like given

I am using Google Bard and ChatGPT to help write an i2c driver for BME280 on XMC1302 with DAVE4.   Neither of these tools can find working DAVE4 example code, but they do generate a decent high level driver based on generic substrate APIs such as I2C_Read, I2C_Write, etc.

Using the zip file  I2C_EXAMPLE_XMC45 that can be downloaded shows a potential pattern to implement the low level I2C substrate functions based on the APIs provided in the bowels of DAVE.

The code snippet posted in this forum post suggests using the XMC library.   It would be very helpful and strongly recommended to also provide the details of the include files (Include DAVE.h and ???) to make it clear how to use XMClib along with DAVE.

Thanks

 

 

0 Likes