Reading data from AD7195 DATA register with ATxmega64A3

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

 

Currently I am working with the ATxmega64A3 which receives information from a load cell through an AD7195 ADC. This ADC works with SPI, the microcontroller is configured as master and the ADC as slave. I am trying to build a function which reads the bits from the DATA register of the ADC. These bits are transferred through the MISO line (if I send a command to read from the DATA register first), if the same amount of bits is transferred through the MOSI line am I correct? This DATA register has 24 bits. So at first I have to send a byte through te MOSI line to tell the ADC that I want to read from the DATA register, after which I have to send 24 bits through the MOSI line to get 24 bits through the MISO line right? I tried this by sending 3 times 1 byte (1 variable of data type char) through the MOSI line. In this case I also receive 3 times 1 byte through the MISO line I figured. My problem however is that I don't know how to store those 3 bytes into 1 variable. I want to use this variable to convert to a decimal number. I tried searching google etc. but unfortunately I didn't find a solution for this problem.

 

Anyone knows how to solve this or have a better suggestion?

 

Thanks in advance,

 

PeterV

Last Edited: Wed. Nov 26, 2014 - 10:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Did you manage the transfer of ad data to atmega?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

PeterVers wrote:
My problem however is that I don't know how to store those 3 bytes into 1 variable.

One way is to shift the variable 8 bits left and then bitwise or the byte for each received byte.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Edward resurrected a 5 year old thread. I don't expect a timely response from Peter (OP).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If this is abut getting code to drive an AD7195 then these days the best way to find "working code" is to see if someone has interfaced it to an Arduino. When I google "Arduino AD7195" one of the top hits was:

 

https://github.com/analogdevices...

 

That has AD7791.cpp and .h - now I don't know similar AD7791 and AD7195 are but the fact that Google brought me here first suggests they could be quite similar.

 

Page 18 in this https://www.analog.com/media/en/... and the command codes in this:

 

https://github.com/analogdevices...

 

do seem to suggest they are very similar!