1 | .INCLUDE "m32def.inc" ; Deklarationen
|
2 | // Takt= 4 MHz
|
3 | .def akku = r16
|
4 | .def temp1 = r21
|
5 | .def temp2 = r22
|
6 | .def temp3 = r23
|
7 | .def temp = r24
|
8 | .def wert_h = r25
|
9 | .def wert_l = r26
|
10 |
|
11 | start:
|
12 | ;STACK initialisieren
|
13 | ldi temp1, LOW(RAMEND)
|
14 | out SPL, temp1
|
15 | ldi temp1, HIGH(RAMEND)
|
16 | out SPH, temp1
|
17 |
|
18 | ; PORT C+ D alles AUSGÄNGE
|
19 | ldi temp, 0b11111111
|
20 | out DDRC, temp
|
21 | out DDRD, temp
|
22 |
|
23 | ldi akku, $10
|
24 | out TWBR, akku
|
25 |
|
26 | ldi akku, (1 << TWINT) | (1 << TWSTA) | (1 << TWEN);
|
27 | out TWCR, akku
|
28 |
|
29 | ldi akku, (0 << TWPS1) | (0 << TWPS0) ;
|
30 | out TWSR, akku
|
31 |
|
32 | rcall lcd_init ; Display initialisieren
|
33 | rcall lcd_clear ; Display löschen
|
34 |
|
35 | ldi temp1, 0b00001110 ; Display ein, Courser ein, Blinken aus
|
36 | rcall lcd_command ; sende Befehl an LCD
|
37 | sbi PORTD, 7 ; Beleuchtung ein
|
38 |
|
39 | clr wert_l
|
40 | clr wert_h
|
41 |
|
42 | rcall i2c_init
|
43 |
|
44 | LOOP:
|
45 |
|
46 | ldi i2cadr,$E0+i2cwr ; Set device address and write
|
47 | rcall i2c_start ; Send start condition and address
|
48 |
|
49 | ldi i2cdata,$0 ; Write word address (0x00)
|
50 | rcall i2c_do_transfer ; Execute transfer
|
51 |
|
52 | ldi i2cdata,$51 ; Set write data to 01010101b
|
53 | rcall i2c_do_transfer ; Execute transfer
|
54 |
|
55 | rcall i2c_stop
|
56 |
|
57 | rcall delay5ms
|
58 |
|
59 | ldi i2cadr,$E0+i2cwr ; Set device address and write
|
60 | rcall i2c_start ; Send start condition and address
|
61 |
|
62 | ldi i2cdata,$02 ; Write word address
|
63 | rcall i2c_do_transfer ; Execute transfer
|
64 |
|
65 | ldi i2cadr,$E0+i2crd ; Set device address and read
|
66 | rcall i2c_rep_start ; Send repeated start condition and address
|
67 |
|
68 | sec ; Set no acknowledge (read is followed by a stop condition)
|
69 | rcall i2c_do_transfer ; Execute transfer (read)
|
70 |
|
71 | rcall i2c_stop ; Send stop condition - releases bus
|
72 |
|
73 | mov wert_h, i2cdata
|
74 |
|
75 |
|
76 | ldi i2cadr,$E0+i2cwr ; Set device address and write
|
77 | rcall i2c_start ; Send start condition and address
|
78 |
|
79 | ldi i2cdata,$03 ; Write word address
|
80 | rcall i2c_do_transfer ; Execute transfer
|
81 |
|
82 | ldi i2cadr,$E0+i2crd ; Set device address and read
|
83 | rcall i2c_rep_start ; Send repeated start condition and address
|
84 |
|
85 | sec ; Set no acknowledge (read is followed by a stop condition)
|
86 | rcall i2c_do_transfer ; Execute transfer (read)
|
87 |
|
88 | rcall i2c_stop ; Send stop condition - releases bus
|
89 |
|
90 | mov wert_l, i2cdata
|
91 |
|
92 |
|
93 | ldi temp1, $80 ; Display ein, Courser ein, Blinken aus
|
94 | rcall lcd_command ; sende Befehl an LCD
|
95 |
|
96 | mov temp2, wert_h
|
97 | mov temp3, wert_l
|
98 | rcall lcd_number16
|
99 |
|
100 | rcall warte_1s
|
101 |
|
102 | rjmp loop ; Loop forewer
|
103 |
|
104 | warte_1s:
|
105 | ; =============================
|
106 | ; Warteschleifen-Generator
|
107 | ; 1000000 Zyklen:
|
108 | ; -----------------------------
|
109 | ; warte 999999 Zyklen:
|
110 | ldi R27, $09
|
111 | WGLOOP3: ldi R28, $BC
|
112 | WGLOOP4: ldi R29, $C4
|
113 | WGLOOP5: dec R29
|
114 | brne WGLOOP5
|
115 | dec R28
|
116 | brne WGLOOP4
|
117 | dec R27
|
118 | brne WGLOOP3
|
119 | ; -----------------------------
|
120 | ; warte 1 Zyklus:
|
121 | nop
|
122 | ; =============================
|
123 | ret
|
124 |
|
125 | .include "lcd-routines.asm" ; include routine für LCD
|
126 | .include "avr300.asm" ; include routine für LCD
|