source: firmware/MSR/src/ad7719_adc.h@ 10734

Last change on this file since 10734 was 10588, checked in by neise, 14 years ago
added MSR Firmware MSR is the little brother of FSC
File size: 2.5 KB
Line 
1#ifndef __AD7719_ADC_H
2#define __AD7719_ADC_H
3//-----------------------------------------------------------------------------
4
5#include "typedefs.h"
6#include "application.h"
7#include "num_conversion.h"
8//-----------------------------------------------------------------------------
9// Bit Definitions
10#define ADC_RDY PD2
11#define ADC_RST PB1
12#define AD7719_IS_READY() (!(PIND & (1<<PD2))) // TRUE if PD2=0 AD_RDY is inverted logic.
13
14
15
16
17
18// ON CHIP REGISTER ADDRESSES
19#define STATUS_RD 0x40
20
21#define MODE_WR 0x01
22#define MODE_RD 0x41
23
24#define AD0CON_WR 0x02
25#define AD0CON_RD 0x42
26
27#define AD1CON_WR 0x03
28#define AD1CON_RD 0x43
29
30#define FILTER_WR 0x04
31#define FILTER_RD 0x44
32
33#define AD0DAT_RD 0x45
34#define AD1DAT_RD 0x46
35
36#define IOCON_WR 0x07
37#define IOCON_RD 0x47
38
39#define AD0OFS_WR 0x08
40#define AD0OFS_RD 0x48
41
42#define AD1OFS_WR 0x09
43#define AD1OFS_RD 0x49
44
45#define AD0GAIN_WR 0x0A
46#define AD0GAIN_RD 0x4A
47
48#define AD1GAIN_WR 0x0B
49#define AD1GAIN_RD 0x4B
50
51#define ID_RD 0x4F
52
53// REGISTER INIT VALUES
54
55 //Init Configure and Initialize AD7719
56 //http://designtools.analog.com/dt/adc/codegen/ad7719.html
57
58#define IOCON_INIT_HIGH 0x03 //0000.0011 // I-sources I1 and I2 are switched on, thats all
59#define IOCON_INIT_LOWBYTE 0x00
60
61#define FILTER_INIT 0x52 //0x52 euro use 50Hz = -171dB and 60Hz = -58dB Rejectjon Updaterate = 4Hz
62 // 0x52=82 decimal. f_ADC=16.6Hz; t_ADC=60ms; t_settle = 120ms
63
64#define AD1CON_INIT 0x31 //0011.0001
65 // AD1EN is set --> AUX ADc is used for Temp measurement.
66 // ACH = 011 --> Tempsensor
67 // U/#B = 0 --> bipolar, but i'm not entirely sure if this is correct.
68 // ARN = 1 --> input range is REFIN2 , but when tempsensor is chosen, internal ref is used ...
69
70#define AD0CON_INIT 0x8E // 1000.1110
71 // AD0EN is set
72 // WL is cleared --> 24bit
73 // CH = 00 --> AIN1 , AIN2 used
74 // U/#B = 1 --> unipolar
75 // RN=110 --> input range = +-1.28V --> whatever this means in ratiometric measurements.
76
77
78#define MODE_IDLE 0x01
79#define MODE_SINGLE 0x02
80#define MODE_CONT 0x03
81#define MODE_INTERNAL_ZERO_CAL 0x04 // not tested
82#define MODE_INTERNAL_FULL_CAL 0x05 // not tested
83
84// since the ADC is chopped, one should wait 3 conversions
85// after the muxer was switched, until the reading is okay.
86#define READINGS_UNTIL_AD7719_SETTLED 3
87
88void ad7719_init(void);
89void startconv(U08 continuous);
90void stopconv(void);
91U32 read_adc(void);
92//-----------------------------------------------------------------------------
93#endif
Note: See TracBrowser for help on using the repository browser.