I2C (IIc USIC Communication with Relax Kit) Problem

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

cross mob
Not applicable
Hi,

iam new in Component Based Programming and have some problems with USIC communication.

Problem:
I scale my SDA (0.5) SCL (0.11) Pins with a Osci but i dont get a Signal ?!? I will control a I2C Display.

Hardware:
XMC4500 Relax Kit

Details:
I2C001/0 (API)
Slave Adress: 0x77

Code:
| START | SLAVE ADRESS | W | A | DATA | A | DATA | A | P |

I2C001_DataType data1,data2,data3,data4,data5;

//START + SLAVE ADRESS + W
data1.Data1.TDF_Type = I2C_TDF_MStart;
data1.Data1.Data = (0x77 | I2C_WRITE);
while (!I2C001_WriteData(&I2C001_Handle0,&data1));

// A + DATA
data4.Data1.TDF_Type = I2C_TDF_MRxAck0; // <<--- ???? I2C_TDF_STxData ? (Slave to Master Ackn.. )
data4.Data1.Data = 0x21;
while (!I2C001_WriteData(&I2C001_Handle0,&data4));

//Start repeat
data3.Data1.TDF_Type = I2C_TDF_MRStart;
data3.Data1.Data = 0x77 | I2C_WRITE;
while (!I2C001_WriteData(&I2C001_Handle0,&data3));

//A + DATA
data4.Data1.TDF_Type = I2C_TDF_MRxAck0;
data4.Data1.Data = 0xA0;
while (!I2C001_WriteData(&I2C001_Handle0,&data4));

// Stop condition by the master
data5.Data1.TDF_Type = I2C_TDF_MStop;
data5.Data1.Data = 0x00;
while (!I2C001_WriteData(&I2C001_Handle0,&data5));

while(1){

}

Have somebody a simple example ?
0 Likes
21 Replies
Not applicable
now i get the Start Condition...but my Clock signal ist High no change
0 Likes
Not applicable
int main(void)
{
//uint16_t IICSlave_addr = I2C003_Handle0.SlaveAddress >> 9;
DAVE_Init(); // Initialization of DAVE Apps

//START + SLAVE ADRESS + W
data1.Data1.TDF_Type = I2C_TDF_MStart;
data1.Data1.Data = (0x77 | I2C_WRITE);
while (!I2C001_WriteData(&I2C001_Handle0,&data1));

// A + DATA
data2.Data1.TDF_Type = I2C_TDF_MTxData ;
data2.Data1.Data = 0x21;
while (!I2C001_WriteData(&I2C001_Handle0,&data2));

// A + DATA
data3.Data1.TDF_Type = I2C_TDF_MTxData ;
data3.Data1.Data = 0xA0;
while (!I2C001_WriteData(&I2C001_Handle0,&data3));


// Stop condition by the master
data4.Data1.TDF_Type = I2C_TDF_MStop;
data4.Data1.Data = ubyteFF;
while (!I2C001_WriteData(&I2C001_Handle0,&data4));
0 Likes
Not applicable
Hi,

I use a simple project to test my Pin's on my xmc Relax Board but i don't get Clock Signal. I use the pins P0.5 P0.11.

somebody have the same problem ?
0 Likes
Not applicable
Hi,

Did you provide the pull-up resistor?
External pull up resistor is required for I2C protocol.

Is this the same question related to this thread - "I2C (IIc USIC Communication with Relax Kit) Problem "
If yes, I shall merge these two thread together.
0 Likes
Not applicable
Yes its nearly same Thread.

I use only Master no Slave's, this means I can use I2C without Pull up.

tanks...
0 Likes
Not applicable
I use only I2C001 App with default configurations,

My Code:


// Configure message data length
I2C001_Type data1,data2,data3,data4,data5,data6;

int main(void)
{

DAVE_Init();

// Configure message data length
I2C001_Type data1,data2,data3,data4;

// Write access IO expander device PCA9502
// Transmission by the master with start condition,
// I2C write condition and slave address
data1.TDF_Type = I2C_TDF_MStart;
data1.Data = (0x77 | I2C_WRITE); //Slave Adress
I2C001_WriteData(&I2C001_Handle0,&data1);

// Write to the direction register
data2.TDF_Type = I2C_TDF_MTxData;
data2.Data = 0x21; //Osc. ON
I2C001_WriteData(&I2C001_Handle0,&data2);

// Write data to configure one bit as output
data3.TDF_Type = I2C_TDF_MTxData;
data3.Data = 0xA0; //ROW
I2C001_WriteData(&I2C001_Handle0,&data3);

// Write data to configure one bit as output
data4.TDF_Type = I2C_TDF_MTxData;
data4.Data = 0x81; //Display ON
I2C001_WriteData(&I2C001_Handle0,&data4);

// Stop condition by the master
data4.TDF_Type = I2C_TDF_MStop;
data4.Data = ubyteFF;
I2C001_WriteData(&I2C001_Handle0,&data4);

while(1)
{}
return 0;
}
0 Likes
Not applicable
Hi,

I don't think you will see the clock signal if no external pull up resistor is connected.
0 Likes
Not applicable
I use external Pull ups 4,7K
0 Likes
Not applicable
989.attach

The Picture shows my circuit structure...




This one is false(Attached).
0 Likes
Not applicable
i also set the pins as Ouput and Open Drain

P0_11_set_mode(OUTPUT_OD_GP);
P0_11_set_driver_strength(STRONG);

P0_5_set_mode(OUTPUT_OD_GP);
P0_5_set_driver_strength(STRONG);
0 Likes
Not applicable
Hi,

I also having problem using that 2 pins (P0.11 and P0.5) on my test. I will investigate further.
Meanwhile, do you mind run your test on P0.8 (SCL) and P1.5 (SDA)?
When I use P0.8 and P1.5 on my Relax kit, it works fine for me.
0 Likes
Not applicable
Do you show me your code example, pleace ?
0 Likes
Not applicable
Hi,

I'm using the I2C001_Example1 from the DAVE example project and changes the pins configuration.
I connect the Relax Kit with the I2C slave on the COM_ETH-V1 board.
Of course, with 4.7K external pull up added.
0 Likes
Not applicable
okey Thank you ....
🙂
0 Likes
Not applicable
How can i clear my TxFIFO Buffer ?

my code holding in this code line...

if(USIC_IsTxFIFOfull(I2CRegs))
{
Result = (bool)FALSE;
}
0 Likes
Not applicable
Hi,

In this line of code, it show that your FIFO buffer is full.
So I believe that the data you write into the TxFIFO did not transmit out, that is why it caused the TxFIFO to be full.
Instead of looking at how to clear the buffer, perhaps you need to find out why the data did not transfer out?
0 Likes
Not applicable
Hi,

Finally I managed to get it working on pin P0.5 and P0.11.
Is not due to software or the device but the hardware connection.
I just re-solder the connection pin for P0.5, P0.11 and GND.
Then I connected it again to the slave on the COM board and now it is working.
0 Likes
Not applicable
Okey Thanks Jackson, do you know how can i Reset the FIFO buffer...

normally i read out the Buffer in this line is that correct?
(in FIFO_Receive_Int_Handler)
I2C001_ReadData(&I2C001_Handle0,&DataReceived);
0 Likes
Not applicable
Yes, that is the correct code to read from RxFIFO.

May I know what do you mean by reset the FIFO?
0 Likes
Not applicable
ok.

I mean with Reset i will clear my Buffer.
0 Likes
Not applicable
Hi,

You can clear the FIFO buffer by the register TRBSCR.FLUSHRB for receive fifo and TRBSCR.FLUSHTB for transmit fifo.
0 Likes