Hallo!
WinAVR 20060421
avr-gcc v4.1.1
CPU ist ATmega8, Makefile ist richtig.
Folgender Code:
1 | [...]
|
2 |
|
3 | int main(void)
|
4 | {
|
5 | unsigned char i;
|
6 |
|
7 | // init ports
|
8 | // PB3-MOSI output
|
9 | // PB4-FSYNC output
|
10 | // PB5-SCK output
|
11 |
|
12 | DDRB = (1<<DDB5)|(1<<DDB4)|(1<<DDB3);
|
13 | DDRD = 0xFF;
|
14 | PORTD = 0x00;
|
15 |
|
16 | // init SPI
|
17 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);
|
18 |
|
19 | while(1)
|
20 | SPI_Send8(0b10101010);
|
21 |
|
22 | return 0;
|
23 | }
|
Der avr-gcc erzeugt daraus folgenden Code:
1 | int main(void)
|
2 | {
|
3 | 116: 88 e3 ldi r24, 0x38 ; 56
|
4 | 118: 87 bb out 0x17, r24 ; 23
|
5 | unsigned char i;
|
6 |
|
7 | // init ports
|
8 | // PB3-MOSI output
|
9 | // PB4-FSYNC output
|
10 | // PB5-SCK output
|
11 |
|
12 | DDRB = (1<<DDB5)|(1<<DDB4)|(1<<DDB3);
|
13 | DDRD = 0xFF;
|
14 | 11a: 8f ef ldi r24, 0xFF ; 255
|
15 | 11c: 81 bb out 0x11, r24 ; 17
|
16 | PORTD = 0x00;
|
17 | 11e: 12 ba out 0x12, r1 ; 18
|
18 |
|
19 | // init SPI
|
20 | SPCR = (1<<SPE)|(1<<MSTR)|(1<<SPR1);
|
21 | 120: 82 e5 ldi r24, 0x52 ; 82
|
22 | 122: 8d b9 out 0x0d, r24 ; 13
|
23 | 124: 8a ea ldi r24, 0xAA ; 170
|
24 | 126: 8f b9 out 0x0f, r24 ; 15
|
25 | 128: 77 9b sbis 0x0e, 7 ; 14
|
26 | 12a: fe cf rjmp .-4 ; 0x128 <main+0x12>
|
27 | 12c: fc cf rjmp .-8 ; 0x126 <main+0x10>
|
28 |
|
29 | 0000012e <_exit>:
|
30 | 12e: ff cf rjmp .-2 ; 0x12e <_exit>
|
Kann mir jemand sagen, warum für die Zeile
1 | DDRB = (1<<DDB5)|(1<<DDB4)|(1<<DDB3);
|
kein Code erzeugt wird? Ich versuche die ganze Zeit, SPI auf meinem
ATmega8 zum laufen zu bringen und wundere mich, warum es nicht geht.
Nun ist es mir klar, die DDR-Register sind nicht entsprechend gesetzt.
Ich habe mich schon gewundert, warum deSimulator von AVR Studio gleich
beim Programmstart zur Zeile "DDRD = 0xFF;" gesprungen ist.
Ich hoffe, jemand hat Rat.
Tobias