Author Topic: ADC 7921  (Read 779 times)

0 Members and 1 Guest are viewing this topic.

Offline lorenrusTopic starter

  • Regular Contributor
  • *
  • Posts: 64
  • Country: it
ADC 7921
« on: July 24, 2020, 08:44:45 am »
Hello everyone

I have to use ADC AD7921.
It is manageable through the SPI device. It is equipped with two analog inputs that can be selected by manipulating a MUX, through SPI.

By default, the Vin0 signal is enabled on the exit from the MUX, which I read correctly with the code I attach.

One thing I noticed is that if I decrease the freq I read incorrect values, and this thing is not clear to me since on the datasheet, p. 7, I find a Freq rage from 10 khz to 5 Mhz. What am I wrong?

Further, he goes to sample in and out on the fall.

On my uC which is a SAMD21 I selected mode 3.

The data that he sends me I receive correctly with mode 3 because, even looking at the time digram, page 7, he samples the DOUT on the falling and I on the uC I read it on the first positive front.

But instead when I send from the uC, always with mode 3, they field on the FALLING and also the ADC on the DIN samples on the FALLING. Could that be the problem?

I attach the code separately to send the channel value.

Ulteriore cosa รจ che guardando il diagramma temporale di pagina 8 si vede che richiede 16 colpi di clock per eseguire tutta la comunicazione; come faccio a far risultare esattamente questo numero di colpi di clock ?

Thank you


Code: [Select]

SPISettings SPI_Settings_Test_14(5000000, MSBFIRST, SPI_MODE3);

void setup() {
     
     Serial.begin(115200);

}

void loop() {

                   // SPI ACTIVED
                    SPI.begin();

                    // BUS SPI ACTIVED
                    SPI.beginTransaction(SPI_Settings_Test_14);

                    //  SLAVE ACTIVED
                    digitalWrite(FPGA_CS_VOLT_NEG, LOW);

                    SPI_Received_Value_BATT_480_VOLT = SPI.transfer16(0);

                    // SLAVE DISABLED
                    digitalWrite(FPGA_CS_VOLT_NEG, HIGH);

                    Serial.println(SPI_Received_Value_BATT_480_VOLT, BIN);

                    // BUS SPI DISABLED
                    SPI.endTransaction();

                    // SPI
                    SPI.end();


                    float Voltage = SPI_Received_Value_BATT_480_VOLT * (5.2/4096);
}



Code: [Select]

// SEND DATA -- CHANNEL VALUE

                    // ABILITO LA COMUNICAZIIONE SPI
                    SPI.begin();

                    // ABILITO IL BUS SPI
                    SPI.beginTransaction(SPI_Settings_Test_14);

                    // ATTIVO LO SLAVE
                    digitalWrite(FPGA_CS_VOLT_NEG, LOW);

                    SPI.transfer16(001000000000000); pag 17

                    // DISATTIVO LO SLAVE
                    digitalWrite(FPGA_CS_VOLT_NEG, HIGH);

                    SPI.endTransaction();

                    SPI.end();

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf