Post Go back to editing

AD7771 and DOUTx interface

Category: Software
Product Number: AD7771

Hi,

I want to read ADC data from AD7771 via DOUT0 line - all 8 channels in 1 line.

What I did:

I am in SPI control mode:

- Set PowerMode to LP

- Set decimation rate (I want ODR = 1 kHz) => 1024/1 = 1024 = 0x400 - to the rigister  SRC_N_MSB I wrote 0x04 and to SRC_N_LSB I wrote 0, then I update it via register 0x64 (SRC_UPDATE)

- Set Output format and DCLK via reg. 0x14 (DOUT_FORMAT) => DOUT_FORMAT = 0b11100100 (1 DOUTx line,CRC header,reserved,MCLK/4,Reserved).

- Set reference to internal via reg. 0x15 (ADC_MUX_CONFIG) => ADC_MUX_CONFIG = 0b01000000

After that I can see:

- DRDY pin has period of 1 khz - perfect!

- On the scope I can see 8x32 bits packets - looks OK to me.

Questions:

- Is OK when after all 8x32 bits packet the CLK still generates cloks even if the data are already sent?

image here:

- Where does the data start (CRC header for channel 0)?:

Finally I tried to read this data by STM32 via SAI interface, but I am not succesful. The discussion is here without answer:  RE: Any advice on reading the AD7779 DOUT0 using an STM32 SAI input? 

Thank you for any advice.

Jan.

Parents
  • Hi   ,

    Regarding the data read using SAI- Attached below are the settings with which I was able to get the data read successfully

    Init:

    Details:{AudioMode = 3, Synchro = 0, SynchroExt = 0, MckOutput = 0, OutputDrive = 0, NoDivider = 0, FIFOThreshold = 0, AudioFrequency = 0, Mckdiv = 0, MckOverSampling = 0, MonoStereoMode = 0, CompandingMode = 0, TriState = 0, PdmInit = {Activation = DISABLE, MicPairsNbr = 0, ClockEnable = 0}, Protocol = 0, DataSize = 64, FirstBit = 0, ClockStrobing = 1}

    FrameInit

    Details:{FrameLength = 256, ActiveFrameLength = 1, FSDefinition = 0, FSPolarity = 0, FSOffset = 0}

    SlotInit:

    Details:{FirstBitOffset = 0, SlotSize = 0, SlotNumber = 32}

    Here it has been configured in such a way that SAI reads 32 slots, where:

    channel0 = (data[1]  << 16 ) | (data[2] << 8) | (data[3])

    channel1 = (data[5]  << 16 ) | (data[6] << 8) | (data[7])

    and so on.

  • Thank you!

    Now I can read the data by STM32!! BUT: I had to change some params:

    1) ClockStrobing to 0 - Data are sampled on Falling edge - datsheet page 9, Figure 2

    2) ActiveFrameLength to 128 - not exactly sure why has to be this value

  • Could you check if the DOUT_FORMAT[7:6] in the DOUT_FORMAT register (Address- 0x14) is set to 10 or 11 to get all data on a single DOUT line?

    Reference: Datasheet - page 74

    www.analog.com/.../ad7771.pdf

  • I set bits [7:6] to 0b11 

    Exactly this:

    uint8_t tmp = 0;

    AD771_ReadFromReg(0x14, &tmp, 1);

    tmp |= (1<<7) | (1<<6); //1 out line for all channels
    tmp &=~ (1<<5); //status header
    tmp |= (4<<1); //DCLK

    AD771_WriteToReg(0x14,&tmp,1);

  • Also I was probably in a hurry. I can read now only first 4 channels. But I'm pretty sure I could read all 8 channels - so had to change something else... 

  • Hi  ,

    I hope you have got answers for all the queries you had. Please confirm that you could read all 8 channels.

    Thanks

    Vikas J

  • Hi, unfortunatelly I can not confirm it.

    The best results  I have got:

    I Can read 4 channels or can read 8 channels but with shift: first byte is on second possition in my rxDataArray,... so I need to read not 32 bytes but 33. So I still do not have the right configuration, cannot find any detailed information about it

  • Finally!

    This variant works to me - reading 8 channels in 1 DOUt line:

    hsai_BlockB3.Instance = SAI3_Block_B;
      hsai_BlockB3.Init.Protocol = SAI_FREE_PROTOCOL;
      hsai_BlockB3.Init.AudioMode = SAI_MODESLAVE_RX;
      hsai_BlockB3.Init.DataSize = SAI_DATASIZE_32;
      hsai_BlockB3.Init.FirstBit = SAI_FIRSTBIT_MSB;
      hsai_BlockB3.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;
      hsai_BlockB3.Init.Synchro = SAI_ASYNCHRONOUS;
      hsai_BlockB3.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
      hsai_BlockB3.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;
      hsai_BlockB3.Init.SynchroExt = SAI_SYNCEXT_DISABLE;
      hsai_BlockB3.Init.MonoStereoMode = SAI_STEREOMODE;
      hsai_BlockB3.Init.CompandingMode = SAI_NOCOMPANDING;
      hsai_BlockB3.Init.TriState = SAI_OUTPUT_NOTRELEASED;
      hsai_BlockB3.Init.PdmInit.Activation = DISABLE;
      hsai_BlockB3.Init.PdmInit.MicPairsNbr = 1;
      hsai_BlockB3.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;
      hsai_BlockB3.FrameInit.FrameLength = 256;
      hsai_BlockB3.FrameInit.ActiveFrameLength = 1;
      hsai_BlockB3.FrameInit.FSDefinition = SAI_FS_STARTFRAME;
      hsai_BlockB3.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW;
      hsai_BlockB3.FrameInit.FSOffset = SAI_FS_FIRSTBIT;
      hsai_BlockB3.SlotInit.FirstBitOffset = 0;
      hsai_BlockB3.SlotInit.SlotSize = SAI_SLOTSIZE_32B;
      hsai_BlockB3.SlotInit.SlotNumber = 8;
      hsai_BlockB3.SlotInit.SlotActive = SAI_SLOTACTIVE_0|SAI_SLOTACTIVE_1|SAI_SLOTACTIVE_2|SAI_SLOTACTIVE_3
    		  	  	  	  	  	  	  	  |SAI_SLOTACTIVE_4|SAI_SLOTACTIVE_5|SAI_SLOTACTIVE_6|SAI_SLOTACTIVE_7;

    Thank you all!

Reply
  • Finally!

    This variant works to me - reading 8 channels in 1 DOUt line:

    hsai_BlockB3.Instance = SAI3_Block_B;
      hsai_BlockB3.Init.Protocol = SAI_FREE_PROTOCOL;
      hsai_BlockB3.Init.AudioMode = SAI_MODESLAVE_RX;
      hsai_BlockB3.Init.DataSize = SAI_DATASIZE_32;
      hsai_BlockB3.Init.FirstBit = SAI_FIRSTBIT_MSB;
      hsai_BlockB3.Init.ClockStrobing = SAI_CLOCKSTROBING_FALLINGEDGE;
      hsai_BlockB3.Init.Synchro = SAI_ASYNCHRONOUS;
      hsai_BlockB3.Init.OutputDrive = SAI_OUTPUTDRIVE_DISABLE;
      hsai_BlockB3.Init.FIFOThreshold = SAI_FIFOTHRESHOLD_EMPTY;
      hsai_BlockB3.Init.SynchroExt = SAI_SYNCEXT_DISABLE;
      hsai_BlockB3.Init.MonoStereoMode = SAI_STEREOMODE;
      hsai_BlockB3.Init.CompandingMode = SAI_NOCOMPANDING;
      hsai_BlockB3.Init.TriState = SAI_OUTPUT_NOTRELEASED;
      hsai_BlockB3.Init.PdmInit.Activation = DISABLE;
      hsai_BlockB3.Init.PdmInit.MicPairsNbr = 1;
      hsai_BlockB3.Init.PdmInit.ClockEnable = SAI_PDM_CLOCK1_ENABLE;
      hsai_BlockB3.FrameInit.FrameLength = 256;
      hsai_BlockB3.FrameInit.ActiveFrameLength = 1;
      hsai_BlockB3.FrameInit.FSDefinition = SAI_FS_STARTFRAME;
      hsai_BlockB3.FrameInit.FSPolarity = SAI_FS_ACTIVE_LOW;
      hsai_BlockB3.FrameInit.FSOffset = SAI_FS_FIRSTBIT;
      hsai_BlockB3.SlotInit.FirstBitOffset = 0;
      hsai_BlockB3.SlotInit.SlotSize = SAI_SLOTSIZE_32B;
      hsai_BlockB3.SlotInit.SlotNumber = 8;
      hsai_BlockB3.SlotInit.SlotActive = SAI_SLOTACTIVE_0|SAI_SLOTACTIVE_1|SAI_SLOTACTIVE_2|SAI_SLOTACTIVE_3
    		  	  	  	  	  	  	  	  |SAI_SLOTACTIVE_4|SAI_SLOTACTIVE_5|SAI_SLOTACTIVE_6|SAI_SLOTACTIVE_7;

    Thank you all!

Children
No Data