Hallo User,
ich versuche eine AD7715 über SPI mit einem Atmega32 auszulesen. Nach dem ich das Datenblatt versucht habe zu lesen komme ich auf folgende Schritte.
http://www.analog.com/static/importe...ets/AD7715.pdf
1. Write to the communications register, setting the gain to 1 with standby inactive.
2. Write to the setup register, setting bipolar mode, buffer off, no filter synchronization, confirming a clock frequency of 2.4576 MHz, setting the output rate for 60 Hz and initiating a self-calibration.
3. Poll the output. DRDY
4. Read the data from the data register.
5. Loop around doing Step 3 and Step 4 until the specified number of samples have been taken.
Hier ist der code mit dem ich versuche den AD7715 auszulesen, es steht nach dem Start immer nur 65353 da. Was habe ich übersehen ?
Hier ist der aktuelle Code:
Code:
'------------------------------------------------------------------------------ '
' Auslesen AD7715 '
' '
'-------------------------------------------------------------------------------'
$regfile = "m32def.dat" 'ATmega 32
$crystal = 16000000 'Quarz: 16 MHz
'$sim
$hwstack = 256
$swstack = 256
$framesize = 256
'-------------------------------------------------------------------------------'
'-------------------------------LED Spannung------------------------------------'
Config Pind.4 = Output 'Pin wird auf High, also 5V geschaltet
Led Alias Portd.4
Led = 1
'-------------------------------------------------------------------------------'
'----------------------------- Config für LCD ----------------------------------'
Config Lcd = 16 * 2
Config Lcdpin = Pin , Db4 = Portc.2 , Db5 = Portc.3 , Db6 = Portc.4 , _
Db7 = Portc.5 , E = Portd.7 , Rs = Portd.5
Config Lcdbus = 4
Initlcd
Cursor Off
Cls
'-------------------------------------------------------------------------------'
Dim Ch As Word
Dim signal_out As Byte
Dout Alias Portb.6 'signal AD7714 OUT
Din Alias Pinb.5 'signal AD7714 IN
Sclk Alias Portb.7 'clockAD7715 CLK
Drdy Alias Pinb.4
'1. Write to the communications register, setting the gain to 1 with standby inactive.
Signal_out = &B00010000
Shiftout Dout , Sclk , Signal_out , 1 , 8
'2. Write to the setup register, setting unipolar mode, buffer off
' no filter synchronization, confirming a clock frequency of 2.4576 MHz
' setting the output rate for 60 Hz and initiating a self-calibration.
Signal_out = &B00101000
Shiftout Dout , Sclk , Signal_out , 1 , 8
'-------------------------------Hauptschleife-----------------------------------'
Do
'3. Poll the output. DRDY
Bitwait Drdy , Set
Bitwait Drdy , Reset
Waitus 10
'4. Read the data from the data register.
Signal_out = &B00110000
Shiftout Dout , Sclk , Signal_out , 1 , 8
Shiftin Din , Sclk , Ch , 1 , 16
Waitus 10
Locate 1 , 1 : Lcd Ch
Loop
'-------------------------------------------------------------------------------'
Grüße Silvio
Lesezeichen