Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

ADCS7476: Getting all output bits as 1 from the ADC

$
0
0

Part Number:ADCS7476

I never used SPI before and I am trying to read the data off the ADC (ADCS7476) and print it on the serial monitor using Arduino Uno. I am using the following code and whatever the input voltage is, I am getting the output as 0xFFFF (65535) from the ADC. Can someone please look at the code and tell me what's wrong with it? Thank you.

#include<SPI.h>
#define cs 10

SPISettings settingsA(250000, MSBFIRST, SPI_MODE0);
byte highbyte,lowbyte;
unsigned int data;

void setup() {
  Serial.begin(9600);
  pinMode(cs, OUTPUT);
  digitalWrite(cs, HIGH); 
  delay(1000);
  SPI.begin();
}

void loop() {
  SPI.beginTransaction(settingsA);
  digitalWrite(cs, LOW);
  delayMicroseconds(1);
  highbyte = SPI.transfer(0xFF);
  lowbyte = SPI.transfer(0xFF);
  digitalWrite(cs, HIGH);
  delayMicroseconds(1);
  SPI.endTransaction();
  data= ((unsigned int)highbyte << 8 ) + lowbyte;
  Serial.println(data);
  delay(100);
}

The code above is printing 65535 to the serial monitor continuously. 


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>