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.
11 years, 8 months ago.
SPI communication
Hello,
Could someone explain me clearly how I can read 24bits ADC data given by ADE7913 Analog Device? by using mbed LPC1768:
http://www.analog.com/static/imported-files/data_sheets/ADE7912_7913.pdf
Regards, Pratik
1 Answer
11 years, 8 months ago.
You need to set format to 8 bit mode. Then set cs low, send the read commandbyte for register 0, send three dummy bytes while reading the 24 bits of the first ADC, raise cs. Then you have to reassemble the 24 bit ADC value from the 3 received bytes. Something like this:
spi.format(8,0); cs=0; spi.write(0x04); msb=spi.write(0xff); mlsb=spi.write(0xff); lsb=spi.write(0xff); cs=1; adc=(msb<<16) + (mlsb<<8) + lsb;