cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
soluwadara
Visitor
Visitor
578 Views
Registered: ‎05-14-2020

AXI IIC- clock output not working

Jump to solution

Hi, 

I am new to Xilinix. I am trying to I2C to read temperature on my Arty Z7-20. Very simple. My problem is that when I probe the SCL output I see no clock output. I only see it being pulled high (the arty z7-20 has pull resistors on board). I tried using the debug option in Xilin and I saw the same thing.  I used all the examples on avnet and hackster to help and I've looked through the questions in this forum but I am still struggling. Attached is a picture of my block diagram. What am I doing wrong? 

1. In some tutorials, they include a constraint file and edit it. I have tried that. And It did not work. 

2. I tried not including a constraint file. It did not work. 

 

Capture.PNGCapture1.PNG

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
soluwadara
Visitor
Visitor
512 Views
Registered: ‎05-14-2020

I figured it out. I think part of the reason was due to my hardwar. I was able to capture 1 clock signal and using what bruce_karaffa had suggested: that I was not constantly reading the interface. I put in a while loop in there and it works!

 

Thanks!

View solution in original post

0 Kudos
3 Replies
bruce_karaffa
Scholar
Scholar
574 Views
Registered: ‎06-21-2017

The clock is only running when the interface is active.  Is your code constantly trying to read the interface?  Is there an I2C device on the other end of the lines and is it powered?

0 Kudos
soluwadara
Visitor
Visitor
550 Views
Registered: ‎05-14-2020

There is an I2C device on the other end and it is powered. It is a temperature sensor. I am using Vtis to write the C code to my fpga. I ran the single application debugger. I created a new configuration as specified here: https://www.hackster.io/j-abate/minized-motor-control-with-i2c-feature-b8e57c#toc-software-build--i2c-project-initial-steps-8

See the code I wrote below (please note that I am an amateur.) I don't know what I am missing in terms of setting up the AXI IIC interface. You mentioned that the clock only runs when the interface is active..what should I do to make it active?

#include <stdio.h>
#include <unistd.h>
#include "platform.h"
#include "xil_printf.h"
#include "xparameters.h"
#include "sleep.h"
#include "xiic.h"
#include "xil_exception.h"
#include "xiic_l.h
 

#define TEMP_ADDR    0X48
u8 iic_dev_addr = TEMP_ADDR;
//XPAR params from xparameters.h
#define IIC_BASE_ADDR   XPAR_AXI_IIC_0_BASEADDR
XIic IicInstance; //IIC device instance

int iic_read (u8 *read_value){
 int status = XST_SUCCESS;
 u8 tx_buff[2];
 u8 rx_buff[1];
 int tx_len = sizeof(tx_buff);
 int rx_len = sizeof(rx_buff);
 int byte_count = 0;
 
 byte_count = XIic_Send(IIC_BASE_ADDR,iic_dev_addr,
   tx_buff,tx_len,XIIC_STOP); 
 if (byte_count !=1){
  status = XST_FAILURE;
  xil_printf("Failure\n");
 }
 
byte_count = XIic_Recv(IIC_BASE_ADDR,iic_dev_addr,
   rx_buff,rx_len,XIIC_STOP);
 if (byte_count != 1){
  status = XST_FAILURE;
  xil_printf("Failure\n");
 }
 if (status == XST_SUCCESS){
  *read_value = rx_buff[0];
 }
 usleep(100000);
 return (status);
}
int signed_to_int(u16 din){
 int sign;
 u16 dout_16b;
 int dout_11b;
 if (din & 0x8000){
  sign = -1;
  dout_16b = (~din) + 1; 
 } else {
  sign = 1;
  dout_16b = din;
 }
 dout_11b = sign * (int)(dout_16b & 0xFF80); // casting to an int and setting the last 7 bits to 0
 // only the 9 MSB matter
 return (dout_11b);
}
int data_to_temp(int din){
 int temp;
 temp = din *.125;
 return temp;
}
int temp_reading(){
u16 x;
u8 rd_lsb, rd_msb;
int i_x;
iic_read(&rd_lsb); // lsb reading
iic_read(&rd_msb); // msb reading
x = (rd_msb<<8) + rd_lsb; // shift msb to [15:8] and add lsb to [7:0];
i_x = signed_to_int(x);
return i_x;
}
int main()
{
 int temp, dout;
    init_platform();
    xil_printf("Hello World\n\r");
    dout = temp_reading();
    temp = data_to_temp(dout);
    xil_printf("Value in buffer: %d \n", temp);
   // cleanup_platform();
    return 0;
}
0 Kudos
soluwadara
Visitor
Visitor
513 Views
Registered: ‎05-14-2020

I figured it out. I think part of the reason was due to my hardwar. I was able to capture 1 clock signal and using what bruce_karaffa had suggested: that I was not constantly reading the interface. I put in a while loop in there and it works!

 

Thanks!

View solution in original post

0 Kudos