Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
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); } }