Ich rate anhand der Namen der IO-Register, dass es für einen Atmega128
sein soll.
Sourcecode #2 kompiliert nicht mit:
AVR Studio 4.12.498 Service Pack 4
GUI Version 4, 12, 0, 491
AVR Simulator 1, 0, 1, 8
ATMEGA8 243
Operating System
Major 4
Minor 10
PlatformID 1
Build 67766446
A
Plugins:
AVRPLUGINAVRASMOBJECT 1, 0, 0, 43
STK500DLL 1, 0, 1, 0
AVRPLUGINAVRGCCPLUGIN 1, 0, 0, 6
Fehlermeldungen im Build-Fenster:
Build started 7.1.2007 at 16:49:44
avr-gcc.exe -mmcu=atmega128 -Wall -gdwarf-2 -O0 -fsigned-char -MD -MP
-MT martin_text.o -MF dep/martin_text.o.d -c ../martin_text.c
../martin_text.c: In function `main':
../martin_text.c:57: error: 'for' loop initial declaration used outside
C99 mode
make: *** [martin_text.o] Error 1
Ich habe statt dem for ein while benutzt
1 | for (;;)
|
2 | {
|
3 | char text[] = "HelloAVR";
|
4 | text[0]='H';
|
5 | text[7]='R';
|
6 | #if 0
|
7 | for(int ci=0; text[ci] != '\0'; ++ci)
|
8 | {
|
9 | putch(text[ci]);
|
10 | }
|
11 | #else
|
12 | {
|
13 | int ci = 0;
|
14 | while(text[ci] != '\0')
|
15 | {
|
16 | putch(text[ci]);
|
17 | ci += 1;
|
18 | }
|
19 | }
|
20 | #endif
|
21 | putch('\n');
|
22 | }
|
Damit funktioniert die Routine im AVR Simulator.