AnsweredAssumed Answered

TWI interface

Question asked by pranay on Dec 18, 2015
Latest reply on Dec 29, 2015 by pranay

Hi,

I am new to TWI protocol. am using BF607 processor whether the written code will configure this protocol or not am not getting. I want to check the register value which i am writing and  by reading it back whether communication happening or not.

I want to communicate to Clockbuffer(PLL)CDCE706 with the TWI interface.

 

When i Keep breakpoint in Readregister function, it is not coming into that function.

Code is as below,

Please give suggestions on this to move forward...

static bool Readregister(uint8_t reg, uint8_t *value)

{

  // write register address

  buffer[0] = reg;

ADI_TWI_RESULT result = adi_twi_Write(tDevice, buffer, 1, true);

  if (result != ADI_TWI_SUCCESS) {

printf("adi_twi_Write failed in Read\n");

  return false;

  }

  // read register value

result = adi_twi_Read(tDevice, value, 1, false);

if (result != ADI_TWI_SUCCESS) {

  printf("adi_twi_Read failed\n");

  return false;

  }

return true;

}

void TWI_driver()

{

     bool bResult;

  uint8_t Value;

 

  /* open the TWI driver in master mode */

  result = adi_twi_Open(1, ADI_TWI_MASTER, driverMemory, ADI_TWI_MEMORY_SIZE, &tDevice);

  /*

  * Use the driver API's to configure TWI

  */

  result= adi_twi_SetBitRate(&tDevice, 100);

  result= adi_twi_SetDutyCycle(&tDevice, 50);

  result= adi_twi_SetPrescale(&tDevice, 10);

  result= adi_twi_SetHardwareAddress(&tDevice, 0x68);     //in place of 2nd argument use master mode address

 

  /* write data to the TWI device using a blocking write */

  result = adi_twi_Write(tDevice, buffer, sizeof(buffer), false);

 

  bResult = Readregister(0x1, &Value);

 

  /* close the TWI driver */

  result = adi_twi_Close(tDevice);

}

Outcomes