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

DAVE™ Forum Discussions

User7282
Level 4
Level 4
Hi.

Today i tried to connect the MPU6050 breakout board from Sparkfun with XMC4500. I tried to adapt the code on I2C001_Example1 with the pins P0.5 and P0.11 and every time i test it, it always enters the interrupt IIC_Prot_Int_Handler (protocol specific interrupt) and stays there. I have one question: if I'm able to get this interrupt, it means that I have the I2C setup correctly configured and I'm only messing up with the data to write, or the I2C setup can be wrong?
0 Likes
7 Replies
Not applicable
Hi,

Hope you can get some hints from "Help request for I2C application in Dave".

BR,
Zain
0 Likes
User7282
Level 4
Level 4
Hi Zain,

I looked at that post and, in fact, that is my base code to do my program. The problem is that i don't know if i have anything wrong with my circuit or it's only with my code.

So if i get an protocol specific interrupt, that means that my circuit is correct and the comunication is working (my code is wrong) or I can't assume that?
0 Likes
Not applicable
Hi,

The protocol specific interrupt occurs in case of a non-acknowledge (PSR.NACK =1). While, the TCSR.TDV flag remains set, but no further transmission will take place.
Why don't you try to step through the code and observe those status flags eg. PSR.NACK & TCSR.TDV? So that you would know when the non-acknowledge happens.
BTW, did you check the baud rate?

BR,
Zain
0 Likes
User7282
Level 4
Level 4
My code is the following:

I2C001_DataType sData;
sData.Data1.TDF_Type = I2C_TDF_MStart;
sData.Data1.Data = (0x68 | I2C_WRITE);
while(!I2C001_WriteData(&I2C001_Handle0,&sData));

//Next write the reggister address that i want to read
sData.Data1.TDF_Type = I2C_TDF_MTxData;
sData.Data1.Data = 0x68;
while(!I2C001_WriteData(&I2C001_Handle0,&sData));

sData.Data1.TDF_Type = I2C_TDF_MStop;
sData.Data1.Data = ubyteFF;
while(!I2C001_WriteData(&I2C001_Handle0,&sData));

The non-acknowledge happens after the first WriteData. The baud rate is 400 kbits/sec.
0 Likes
Not applicable
Hi,

The 1st transmission is the master initiating the start condition with the slave. Are you able to see the toggling on SDA & SCL during stepping (Both should stay "H" during idle)? Can you confirm the slave address "0x68"?
0 Likes
User7282
Level 4
Level 4
Yes, the master slave is correct. Both SDA and SCL stay H during idle, I will see with a Oscilloscope if the signals match what i want, i dont see any other reason to this error.

Thank you for your help.
0 Likes
Not applicable
Hi,

Do you mean that you can see the correct toggling signals from the oscilloscope but you still receive non-acknowledge interrupt? It seems that the slave can't recognize the data you sent. Sorry, I have no idea as well:(
Why not try to disable all protocol specific interrupts by un-checking all the interrupts listed in the "Interrupt Configuration" tab (re-confirm the PCR register setting in debug mode) and see whether you can step further?

BR,
Zain
0 Likes