cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
AwadZafar
Visitor
Visitor
313 Views
Registered: ‎05-02-2021

I2C implementation error on Zynq

Dear Members,

While implementing I2C via ZYNQ EMIO pins, as shown in attached figures, SCL and SDA lines show garbage data. I tried to implement the I2C protocol via MIO as well as via AXI IIC IP Core but in vain. Both SCL and SDA pins are pulled up as well .Please look into the code as well as attached output of LA. Any help will be highly appreciated. 

Regards.

//CODE

#include "xparameters.h"
#include "xiicps.h"
#include "xil_printf.h"
#include <stdio.h>
#include "sleep.h"

#define size 8
u8 sendbuffer[size];
XIicPs Iic;

int main(){
int Status;
int Index;
XIicPs_Config *Config;


Config = XIicPs_LookupConfig(XPAR_XIICPS_0_DEVICE_ID);
if(NULL==Config){
return XST_FAILURE;
}

Status = XIicPs_CfgInitialize(&Iic,Config,Config->BaseAddress);
if(Status != XST_SUCCESS){
return XST_FAILURE;
}


Status= XIicPs_SelfTest(&Iic);
if(Status != XST_SUCCESS){
return XST_FAILURE;
}

XIicPs_SetSClk(&Iic, 100000);

for (Index=0; Index < size; Index++){
sendbuffer[Index]=(1);
}

Status = XIicPs_MasterSendPolled(&Iic,sendbuffer,1,0x10c);
if(Status != XST_FAILURE){
return XST_SUCCESS;
}

return (Status);
}

 

 

 

Tags (2)
block diagram.PNG
EMIO Configuration.PNG
pins configuration.PNG
i2c output.PNG
0 Kudos
6 Replies
venui
Moderator
Moderator
237 Views
Registered: ‎04-09-2019

Hi @AwadZafar Are you sure that I2C lines are pulled up externally or not, if yes please probe those lines with Oscilloscope and re-confirm the same.

Regards,

Venu

0 Kudos
AwadZafar
Visitor
Visitor
201 Views
Registered: ‎05-02-2021

Thanks @venui. Dear I didn't pulled them up externally. I will let you know the behaviour of waveform after doing the same.

Regards,

Awad Zafar

0 Kudos
AwadZafar
Visitor
Visitor
186 Views
Registered: ‎05-02-2021

Dear @venui,  I pulled up SDA and SCL lines externally by 3.3k ohm resistors and probed them with oscilloscope, however, no positive results are achieved.

Regards.

Awad Zafar

0 Kudos
venui
Moderator
Moderator
175 Views
Registered: ‎04-09-2019

Hi @AwadZafar Can you please share scope shots.

Regards,

Venu

0 Kudos
AwadZafar
Visitor
Visitor
158 Views
Registered: ‎05-02-2021

Dear @venui , PFA of screenshot of scope. I set rising edge of clock as triggered value; SDA line showed no response. Debugging of code showed failure status of 

Status = XIicPs_MasterSendPolled(&Iic,sendbuffer,1,0x10c);
if(Status != XST_FAILURE){
return XST_SUCCESS;
}

Note: SDA and SCL are pulled up externally by 3.3k ohm resistors.

 

Regards,

Awad Zafar

RTOScreenshot_2021-05-07_0_090517.png
0 Kudos
venui
Moderator
Moderator
154 Views
Registered: ‎04-09-2019

Hi @AwadZafar Please use attached source code and test once.

Regards,

Venu

0 Kudos