genp

ADAU1761 Readback reading problem

Discussion created by genp on Jul 25, 2018

I need to read RMS values using readback cell on ADAU1761.

I did it quite a few times before on other DSPs without any problems.

According to the SigmaStudio log it's done by direct reading from the readback cell.

This is the code I am using:

 

volatile uint32_t val32;

 

/* convert 4 8-bit values to 32 bit */ 
typedef union
{
uint8_t rbuf[4];
uint32_t rbuf32;
} buf8to32;

buf8to32 buf32;

 

/* read */
DSP_read((uint16_t)RMS_readback1_ad,4,buf32.rbuf);
val32 = __rev(buf32.rbuf32); /* convert 4 8-bit to 32-bit, endianness */

 

Value I get is always incorrect,

It seems like the only way to get a correct value is to use 2 reads in a row:

 

DSP_read((uint16_t)RMS_readback1_ad,4,buf32.rbuf);
DSP_read((uint16_t)RMS_readback1_ad,4,buf32.rbuf);
val32 = __rev(buf32.rbuf32); /* convert 4 8-bit to 32-bit, endianness */

 

Now almost 100% of time the value is correct.

I've never seen anything like this before.

What could be a reason for such behavior?

 

Thank you,

Gennady

Outcomes