9 years, 2 months ago.

how to read the data from MISO pin, and how can I creat 96 clock ?

I have a question about the SPI read from slave. My ADC has six channel, so I need 96 clock. I wonder that is my code as follows correct?

-----

SPI spi(p5, p6, p7); mosi, miso, sclk

DigitalOut cs(p8);

int main() {

Select the device by setting chip select low

cs = 0;

Send 0x8f, the command to read the WHOAMI register

float CH_A0 = spi.write(0x00);

float CH_A1 = spi.write(0x00);

float CH_B0 = spi.write(0x00);

float CH_B1 = spi.write(0x00);

float CH_C0 = spi.write(0x00);

float CH_C1 = spi.write(0x00);

printf("CH_A0 = %f\n", CH_A0);

printf("CH_A1 = %f\n", CH_A1);

printf("CH_B0 = %f\n", CH_B0);

printf("CH_B1 = %f\n", CH_B1);

printf("CH_C0 = %f\n", CH_C0);

printf("CH_C1 = %f\n", CH_C1);

Deselect the device

cs = 1;

}

---

Be the first to answer this question.