UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Observer likeyou614
Observer
6,796 Views
Registered: ‎01-12-2009

EDK IIC write

In TestApp _ Peripheral =>souce 
 If I hope IIC to write one data device outside
Is that written like this mistakenly? Why seem not to write? '
Suppose I set up as follows
device address =0x4C;
register address =0x03;
data =0x64;

Could you tell me where is the mistake?  thank ............
 
//-----------------------------------------------------------------------------------------------------------------------------
 
int main (void) {
Xuint8 xdata[2];
 xdata[0]=0x03;
 xdata[1]=0x64;
vsk_iic_write(XPAR_IIC_0_BASEADDR, 0X4C, xdata[0],&xdata[1],1);
}
//---------------------------------------------------------------------------------------------------------------
 
Xuint8  vsk_iic_write(Xuint32 CoreAddress, Xuint8 ChipAddress, Xuint8 RegAddress,
                  Xuint8 *BufferPtr, Xuint8 ByteCount)
{
  Xuint8 SentByteCount;
  Xuint8 WriteBuffer[10];
  Xuint8 Index;
  
       
  /*
   * A temporary write buffer must be used which contains both the address
   * and the data to be written, put the address in first
   */
  WriteBuffer[0] = RegAddress;
  /*
   * Put the data in the write buffer following the address.
   */
  for (Index = 0; Index < ByteCount; Index++)
  {
    WriteBuffer[Index + 1] = BufferPtr[Index];
  }
  /*
   * Write data at the specified address.
   */
  SentByteCount = XIic_DynSend(CoreAddress, ChipAddress, WriteBuffer,
                               ByteCount + 1, XIIC_STOP);
  if (SentByteCount < 1) { SentByteCount = 1; }
                              
  // Return the number of bytes written.
  return SentByteCount - 1;
}
 
//-----------------------------------------------------------------------------------------------------------------------------------
 
0 Kudos
5 Replies
Visitor tvdevnull
Visitor
6,741 Views
Registered: ‎03-12-2009

Re: EDK IIC write

Have you tried simplifying the code by calling XIic_DynSend() from main() and verifying that it works?

 

 

int main(void)

{

Xuint8 xdata[2];
xdata[0]=0x03;
xdata[1]=0x64;

XIic_DynSend(XPAR_IIC_0_BASEADDR, 0x4C, xdata, sizeof(xdata), XIIC_STOP);

 

return 0;

}

 

 

0 Kudos
Highlighted
Observer likeyou614
Observer
6,737 Views
Registered: ‎01-12-2009

Re: EDK IIC write

Hi,tedevnull...

I have tried your method, but has not succeeded 
Do you have relevant examples? Could post or send for my reference!
Thanks 


E _ mail: yzliao@j92a21.ee.ncku.edu.tw

0 Kudos
Observer likeyou614
Observer
6,676 Views
Registered: ‎01-12-2009

Re: EDK IIC write

I do not know well, what differences do these two functions?

XIic _ Send(u32 BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option)
XIic _ DynSend(u32 BaseAddress, u8 Address, u8 *BufferPtr, unsigned ByteCount, u8 Option)

Can you explain with me?
Thanks!
 

0 Kudos
Contributor
Contributor
4,994 Views
Registered: ‎05-04-2010

Re: EDK IIC write

Hello,

 

So what indeed is the difference between them?

 

Waiting for your reply,

Haz88

0 Kudos
Explorer
Explorer
4,290 Views
Registered: ‎06-25-2008

Re: EDK IIC write

Dyn_send doesn't use interrupts.

0 Kudos