Hi,
I'm trying to get a ADC chip with SPI inteface running but I'm new to SPI and I'm running into some problems. A timing diagram can be seen below:
I set up the SPI interface to:
spi.format(8,3);
spi.frequency(1000000);
signal = 2; //analog pin 18 on mbed
cs = 1;
cs = 0;
Based on the timing diagram, should I do the following:
spi.write(0xFF); //command to setup the chip assuming
//assuming that it's correct
int whoami = spi.write(0x00);
pc.printf("WHOAMI register = %d\n\r", whoami);
whoami = spi.write(0x00);
pc.printf("WHOAMI register = %d\n\n\r", whoami);
Or should I do:
spi.write(0xFF); //command to setup the chip assuming
//assuming that it's correct
int whoami = spi.write(0x00);
pc.printf("WHOAMI register = %d\n\r", whoami);
spi.write(0xFF); //command to setup the chip assuming
whoami = spi.write(0x00);
pc.printf("WHOAMI register = %d\n\n\r", whoami);
The first version of the code will display 2 integers but they do not seem to be consistent. They might be ball park close for 2-5 times and then another set of numbers appears. The second version of the code outputs a "0" for the second pc.printf statement so I'm not sure on it. I'll go over my wiring again tomorrow and post a diagram, but if anyone has any suggestions than it would be greatly appreciated.
Thanks
Sebastian
Hi,
I'm trying to get a ADC chip with SPI inteface running but I'm new to SPI and I'm running into some problems. A timing diagram can be seen below:
I set up the SPI interface to:
Based on the timing diagram, should I do the following:
Or should I do:
The first version of the code will display 2 integers but they do not seem to be consistent. They might be ball park close for 2-5 times and then another set of numbers appears. The second version of the code outputs a "0" for the second pc.printf statement so I'm not sure on it. I'll go over my wiring again tomorrow and post a diagram, but if anyone has any suggestions than it would be greatly appreciated.
Thanks Sebastian