Jump to content
  • 0

AD5933 doesn't back register values


milad

Question

I'm using the ASF in Atmel Studio for i2c interface which works fine, but when I want to read data from any register the slave generates 0x00. Plus, I connect the MCLK pin to external 1MHz frequency.

This is my code for temperature measurement:

 

//sets the register pointer

void setPointer(unsigned char address)
{
   uint8_t buffer[2] = { 0xB0, address };      //0xB0: pointer command, address: the address that master point to
   twi_package_t packet_write = {
      .chip = 0x0D,
      .buffer = buffer,
      .length = 2,
      .no_wait = false
   };
   twi_master_write(&TWIC, &packet_write);
   while(slave.result != TWIS_RESULT_OK);
}

 

//sends the address register and data register

void sendByte(unsigned char address, unsigned char data)
{
   uint8_t buffer[2] = { address, data };
   twi_package_t packet_write = {
      .chip = 0x0D,
      .buffer = buffer,
      .length = 2,
      .no_wait = false
   };
   twi_master_write(&TWIC, &packet_write);
   while(slave.result != TWIS_RESULT_OK);
}

 

//read a byte from AD5933

unsigned int getByte(unsigned char reg_loc)
{
   setPointer(reg_loc);
   uint8_t buffer[1];
   twi_package_t packet_read = {
      .chip = 0x0D,
      .buffer = buffer,
      .length = 1,
      .no_wait = false
   };
   while (twi_master_read(&TWIC, &packet_read) != TWI_SUCCESS);
   return slave.receivedData[TWIS_RECEIVE_BUFFER_SIZE];
}

 

void main()

{

   init_i2c();

   sendByte(0x80, 0x90);      // put the 0x90 value into the control register (0x80)

   delay_ms(50);

   while(1)

   {

      getByte(0x80)//I expect it returns 0x90 but it returns 0x00

      //data processing for temperature value

   }

}

 

But it always stays at while(getByte(0x8F) != 0x01);

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Hi @milad,

Welcome to the forums. Unfortunately, we haven't had time to make a library for the Pmod IA that uses the AD5933 . Here is a forum thread that has a link to a Raspberry pi project using the PmodIA that should be a good reference. They also have some good calibration suggestions. 

thank you,

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...