Hi zusammen,
ich versuche einen Max531 DAC an einem Atmega32 mit Bascom zum laufenzu
bekommen. Leider funktioniert es nicht so recht.
Die Kommunikation zwischen Max531 und Atmega läuft, nur kann ich keine
Spannung richtig einstellen. Ich bekomm zwar verschiedene Spannungen
raus, aber diese stimmen nicht:
Wert 4095 -> 4,1 V -> passt
Wert 0 -> 0,1 V -> passt
Wert 2047 -> 4,0 V -> passt nicht sollte ca 2 V sein
Hier mal mein Code:
1 | $regfile = "m32def.dat"
|
2 | $crystal = 4000000
|
3 |
|
4 |
|
5 | Config Lcd = 16 * 2
|
6 | Config Lcdpin = Pin , Rs = Portd.6 , E = Portd.5 , Db4 = Portd.4 , Db5 = Portd.3 , Db6 = Portd.2 , Db7 = Portd.1
|
7 | Config Lcdbus = 4
|
8 | Cursor Off Noblink
|
9 | Cls
|
10 |
|
11 |
|
12 | Config Date = Dmy , Separator = .
|
13 | Config Clock = Soft , Gosub = Sectic
|
14 | Enable Interrupts
|
15 | Date$ = "01.01.10"
|
16 | Time$ = "00:00:01"
|
17 |
|
18 |
|
19 | Config Spi = Soft , Din = Pina.3 , Dout = Porta.1 , Ss = Porta.2 , Clock = Porta.0 , Spiin = Value
|
20 | Spiinit
|
21 | Config Porta.3 = Output
|
22 | Dac_clear Alias Porta.3
|
23 | Dac_clear = 1
|
24 |
|
25 |
|
26 | Config Portc.0 = Output
|
27 | Licht Alias Portc.0
|
28 | Licht = 0
|
29 |
|
30 | Config Pinb.0 = Input
|
31 |
|
32 |
|
33 |
|
34 |
|
35 | Dim A(10) As Byte
|
36 | Dim Dac_wert(2) As Byte
|
37 |
|
38 | Dim Dac_wert_lang As Word
|
39 | Dim Dimmwert As Word
|
40 |
|
41 | Dac_wert_lang = 0
|
42 |
|
43 |
|
44 |
|
45 | 'ENTWEDER SO
|
46 |
|
47 | A(1) = &B1111 'Dummy
|
48 | A(2) = &B0111 'Wert1
|
49 | A(3) = &B1101 'Wert2
|
50 | A(4) = &B0000 'Wert3
|
51 |
|
52 | Dac_wert(1) = A(1) And A(2)
|
53 | Dac_wert(2) = A(3) And A(4)
|
54 |
|
55 | Dac_wert_lang = Dac_wert(1) And Dac_wert(2)
|
56 |
|
57 |
|
58 |
|
59 | 'ODER SO
|
60 |
|
61 |
|
62 | Dac_wert_lang = 2047
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 | Spiout Dac_wert_lang , 2
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 | Do
|
75 |
|
76 |
|
77 |
|
78 | Loop
|
79 |
|
80 |
|
81 | End
|
Ich hoffe mir kann jemand helfen.
Grüsse