cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Observer
Observer
6,856 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
Highlighted
Visitor
Visitor
6,801 Views
Registered: ‎03-12-2009

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
Observer
6,797 Views
Registered: ‎01-12-2009

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
Highlighted
Observer
Observer
6,736 Views
Registered: ‎01-12-2009

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
Highlighted
Anonymous
Not applicable
5,054 Views

Hello,

 

So what indeed is the difference between them?

 

Waiting for your reply,

Haz88

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

Dyn_send doesn't use interrupts.

0 Kudos