AD7190 to MBED with SPI

11 Jun 2012

I'm trying to make a SPI communication between the mbed and a 24 bits ADC AD7190. But the results of the printf are always 0 and i don't know how to solve the problems. Can i get some help ? Here is my code :

#include "mbed.h"

DigitalOut cs(p8);
DigitalOut led(LED1);


SPI device(p5, p6, p7); // p5: mosi/DIN, p6 : miso/DOUT, p7 : sclk;

Serial pc(USBTX, USBRX); // tx, rx

int main() {
    //pc.attach(&send_data);
    device.format(8,0);//8 bits
    device.frequency(1000000);  // 1MHz
    char start;// poids faibles
    char middle;//milieu
    char end;//poids fort

    while (1) {

            cs=0;
            wait(0.2);
            device.write(0x58);// communication register
            wait(0.1);
            start = (device.write(0xFF));//read the data register
            wait(0.1);
            middle =(device.write(0xFF));
            wait(0.1);
            end =(device.write(0xFF));
            cs=1;
                    
            
            pc.printf("LSB=%u\n\r",end);
            pc.printf("MIDDLE=%u\n\r",middle);
            pc.printf("MSB=%u\n\r\n\r",X);
                    
            
    }

}
11 Jun 2012

If I am correctly reading the datasheet of the AD7190, it uses SPI mode 4. No idea of that alone is sufficient to explain your problems, but it is worth a try. (I really dislike whoever had the idea that we need 4 different SPI modes that don't add anything besides confusion).

If that doesnt solve your problem, I would try reading the ID register. If that doesnt work you know for sure there is no correct communication.

12 Jun 2012

Thank you Erik , i will try this !