msp430 gcc4 / asm-files assembler umsetzen & einbinden

OP #2218711
Lesenswert?

Hallo zusammen,

versuche gerade die Code-Beispiele von TI für den MSP430 auf GCC4 
umzusetzen. Verwende einen MSP430F449.
http://focus.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=slaa290a

Mit den ASM files habe ich noch Schwierigkeiten.

ORIGINAL RTC_WDT.asm
1
            .cdecls C,LIST,"msp430.h"
2
            .ref  incrementSeconds
3
            .def  WDT_1sec_wake
4

5
            .text
6
WDT_1sec_wake
7
            mov.w   #WDT_ADLY_1000, &WDTCTL ; WDT 1 second interrupt
8
            bis.b   #WDTIE,&IE1             ; Enable WDT interrupt
9
            bis.b   #GIE,  SR
10
            ret
11
;-----------------------------------------------------------------------------
12
WDT_ISR;
13
;-----------------------------------------------------------------------------
14
            call    #incrementSeconds       ; tick one second
15
            reti                            ;    
16
                                            ;
17

18
;-----------------------------------------------------------------------------
19
;           Interrupt Vectors Used
20
;-----------------------------------------------------------------------------
21
            .sect   WDT_VECTOR               ; WDT Vector
22
            .short  WDT_ISR                  ;
23
            .end


und meine
UMSETZUNG RTC_WDT.asm
für msp430 gcc4
1
;            .cdecls C,LIST,"msp430.h"
2
;            .ref  incrementSeconds
3
;            .def  WDT_1sec_wake
4
#include "msp430x44x.h"
5
#include "wdt_a.h"
6

7
            .text
8
.global WDT_1sec_wake
9
WDT_1sec_wake:
10
            mov.w   #WDT_ADLY_1000, &WDTCTL ; WDT 1 second interrupt
11
            bis.b   #WDTIE,&IE1             ; Enable WDT interrupt
12
            bis.b   #GIE,  SR
13
            ret
14
;-----------------------------------------------------------------------------
15
.global WDT_ISR
16
WDT_ISR:
17
;-----------------------------------------------------------------------------
18
            call    #incrementSeconds       ; tick one second
19
            reti                            ;
20
                                            ;
21

22
;-----------------------------------------------------------------------------
23
;           Interrupt Vectors Used
24
;-----------------------------------------------------------------------------
25
            .sect   WDT_VECTOR               ; WDT Vector
26
            .short  WDT_ISR                  ;
27
            .end


Der Builder sagt:
1
**** Rebuild of configuration Debug for project versuch ****
2

3
**** Internal Builder is used for build               ****
4
msp430-gcc.exe -IC:\mspgcc4\msp430\include -O3 -g3 -Wall -c -fmessage-length=0 -mmcu=msp430x449 -o_test\WDT_example.o ..\_test\WDT_example.c
5
../_test/WDT_example.c:81: warning: return type of `main' is not `int'
6
msp430-as.exe -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC_WDT.o ..\_test\RTC_WDT.asm
7
msp430-as.exe -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC.o ..\_test\RTC.asm
8
msp430-gcc.exe -mmcu=msp430x449 -oversuch.elf _test\WDT_example.o _test\RTC_WDT.o _test\RTC.o
9
_test\RTC_WDT.o: In function `WDT_1sec_wake':
10
(.text+0x2): undefined reference to `WDT_ADLY_1000'
11
_test\RTC_WDT.o: In function `WDT_1sec_wake':
12
(.text+0x4): undefined reference to `WDTCTL'
13
_test\RTC_WDT.o: In function `WDT_1sec_wake':
14
(.text+0x8): undefined reference to `WDTIE'
15
_test\RTC_WDT.o: In function `WDT_1sec_wake':
16
(.text+0xa): undefined reference to `IE1'
17
_test\RTC_WDT.o: In function `WDT_1sec_wake':
18
(.text+0xe): undefined reference to `GIE'
19
_test\RTC_WDT.o: In function `WDT_1sec_wake':
20
(.text+0x10): undefined reference to `SR'
21
Build error occurred, build is stopped
22
Time consumed: 1266  ms.

Die references von WDT_ADLY_1000, WDTCTL, WDTIE, IE1, GIE, SR sind in 
"wdt_a.h" definiert.
Warum findet der ggc4 sie nicht? Oder habe ich was falsch deklariert?

Grüße
Moderator Persönliche Seite #2218976
Lesenswert?

Du rufst den Assembler direkt auf, der hat keine Ahnung, was ein
#include ist.  Vermutlich wird ihm das # einfach ein Kommentar-
zeichen sein. ;-)

Der gängige Weg ist es, die Datei mit dem Suffix .S zu benennen
(großes "S"!) und sie dem Compiler zum Fraß vorzuwerfen.  Das große
S ist dem ein Zeichen, dass er die Datei zuerst durch den Präprozessor
jagen soll und dann dem Assembler füttern.

All die Konstanten da drin, die dir der Linker anmeckert, sollte der
Assembler gar nicht mehr symbolisch sehen, sondern bereits durch den
Präprozessor aufgelöst numerisch.  Unix-Assembler (zu denen der GNU
Assembler gehört) beklagen sich jedoch nicht über Dinge, die sie nicht
kennen, sondern nehmen sie stillschweigend als "global undefined" in
die Symboltabelle auf, in der Hoffnung, dass der Linker das dann schon
irgendwie parat haben wird.  Daher kommt die Meckerei nicht vom
Assembler selbst, sondern erst vom Linker.
OP #2220044
Lesenswert?

Vielen Dank für die Info!
Dateiname aus RTC_WDT.S geändert.

Jedoch
1
            .cdecls C,LIST,"msp430.h"
2
            .ref  incrementSeconds
3
            .def  WDT_1sec_wake
4

5
            .text
6
.global WDT_1sec_wake
7
WDT_1sec_wake:
8
            mov.w   #WDT_ADLY_1000, &WDTCTL ; WDT 1 second interrupt
9
            bis.b   #WDTIE,&IE1             ; Enable WDT interrupt
10
            bis.b   #GIE,  SR
11
            ret
12
;-----------------------------------------------------------------------------
13
.global WDT_ISR
14
WDT_ISR:
15
;-----------------------------------------------------------------------------
16
            call    #incrementSeconds       ; tick one second
17
            reti                            ;    
18
                                            ;
19

20
;-----------------------------------------------------------------------------
21
;           Interrupt Vectors Used
22
;-----------------------------------------------------------------------------
23
            .sect   WDT_VECTOR               ; WDT Vector
24
            .short  WDT_ISR                  ;
25
            .end

liefert:
1
**** Rebuild of configuration Debug for project versuch ****
2

3
**** Internal Builder is used for build               ****
4
msp430-as.exe -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC.o ..\_test\RTC.S
5
msp430-gcc.exe -IC:\mspgcc4\msp430\include -O3 -g3 -Wall -c -fmessage-length=0 -mmcu=msp430x449 -o_test\WDT_example.o ..\_test\WDT_example.c
6
../_test/WDT_example.c:81: warning: return type of `main' is not `int'
7
msp430-as.exe -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC_WDT.o ..\_test\RTC_WDT.S
8
..\_test\RTC_WDT.S: Assembler messages:
9
..\_test\RTC_WDT.S:75: Error: unknown pseudo-op: `.cdecls'
10
..\_test\RTC_WDT.S:76: Error: unknown pseudo-op: `.ref'
11
..\_test\RTC_WDT.S:77: Error: unknown pseudo-op: `.def'
12
Build error occurred, build is stopped
13
Time consumed: 968  ms.

und
1
;auskommentiert            .cdecls C,LIST,"msp430.h"
2
;auskommentiert            .ref  incrementSeconds
3
;auskommentiert            .def  WDT_1sec_wake
4

5
            .text
6
.global WDT_1sec_wake
7
WDT_1sec_wake:
8
            mov.w   #WDT_ADLY_1000, &WDTCTL ; WDT 1 second interrupt
9
            bis.b   #WDTIE,&IE1             ; Enable WDT interrupt
10
            bis.b   #GIE,  SR
11
            ret
12
;-----------------------------------------------------------------------------
13
.global WDT_ISR
14
WDT_ISR:
15
;-----------------------------------------------------------------------------
16
            call    #incrementSeconds       ; tick one second
17
            reti                            ;    
18
                                            ;
19

20
;-----------------------------------------------------------------------------
21
;           Interrupt Vectors Used
22
;-----------------------------------------------------------------------------
23
            .sect   WDT_VECTOR               ; WDT Vector
24
            .short  WDT_ISR                  ;
25
            .end

liefert
1
**** Rebuild of configuration Debug for project versuch ****
2
**** Internal Builder is used for build               ****
3
msp430-as.exe -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC_WDT.o ..\_test\RTC_WDT.S
4
msp430-as.exe -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC.o ..\_test\RTC.S
5
msp430-gcc.exe -IC:\mspgcc4\msp430\include -O3 -g3 -Wall -c -fmessage-length=0 -mmcu=msp430x449 -o_test\WDT_example.o ..\_test\WDT_example.c
6
../_test/WDT_example.c:81: warning: return type of `main' is not `int'
7
msp430-gcc.exe -mmcu=msp430x449 -o20110606.elf _test\WDT_example.o _test\RTC_WDT.o _test\RTC.o
8
_test\RTC_WDT.o: In function `WDT_1sec_wake':
9
(.text+0x2): undefined reference to `WDT_ADLY_1000'
10
_test\RTC_WDT.o: In function `WDT_1sec_wake':
11
(.text+0x4): undefined reference to `WDTCTL'
12
_test\RTC_WDT.o: In function `WDT_1sec_wake':
13
(.text+0x8): undefined reference to `WDTIE'
14
_test\RTC_WDT.o: In function `WDT_1sec_wake':
15
(.text+0xa): undefined reference to `IE1'
16
_test\RTC_WDT.o: In function `WDT_1sec_wake':
17
(.text+0xe): undefined reference to `GIE'
18
_test\RTC_WDT.o: In function `WDT_1sec_wake':
19
(.text+0x10): undefined reference to `SR'
20
Build error occurred, build is stopped
21
Time consumed: 1375  ms.


Wie kann man ihm die references von WDT_ADLY_1000, WDTCTL, WDTIE, IE1, 
GIE, SR beibringen?
Muss mann noch an den Linker Flags was drehen?

Grüße
Moderator Persönliche Seite #2220118
Lesenswert?

J. R. schrieb:

> msp430-as.exe -mmcu=msp430x449 -IC:\mspgcc4\msp430\include ...

Du sollst bitte den Compiler aufrufen damit, nicht den Assembler.

Das Kommando "msp430-gcc" (das .exe darfst du dir getrost klemmen)
ist der sogenannte Compiler-Treiber, der die einzelnen Stufen der
"Backends" anhand der Dateiendung der Quelldatei ermittelt und der
Reihenfolge nach aufruft.  Der braucht (außer den -I-Optionen) nur
noch die Option -c, für "compilier' das mal".

> Muss mann noch an den Linker Flags was drehen?

Nein, zum Geier[tm].  Der Linker hat damit nichts zu tun, diese
Konstanten sollen bereits vor dem Assemblieren in Zahlen verwandelt
werden, und dafür zuständig ist der Präprozessor.

Der Linker hat exakt Null Ahnung davon, was ein WDT_ADLY_1000 sein
könnte, und der muss diese Ahnung auch nicht haben.
OP #2220163
Lesenswert?

Ergebnis vom Geier :-/
1
**** Rebuild of configuration Debug for project Versuch ****
2

3
**** Internal Builder is used for build               ****
4
msp430-gcc -c -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC_WDT.o ..\_test\RTC_WDT.S
5
../_test/RTC_WDT.S: Assembler messages:
6
../_test/RTC_WDT.S:75: Error: unknown pseudo-op: `.cdecls'
7
../_test/RTC_WDT.S:76: Error: unknown pseudo-op: `.ref'
8
../_test/RTC_WDT.S:77: Error: unknown pseudo-op: `.def'
9
Build error occurred, build is stopped
10
Time consumed: 484  ms.
OP #2220179
Lesenswert?

bzw
1
**** Rebuild of configuration Debug for project versuch ****
2

3
**** Internal Builder is used for build               ****
4
msp430-gcc -c -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC.o ..\_test\RTC.S
5
msp430-gcc -c -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC_WDT.o ..\_test\RTC_WDT.S
6
msp430-gcc -IC:\mspgcc4\msp430\include -O3 -g3 -Wall -c -fmessage-length=0 -mmcu=msp430x449 -o_test\WDT_example.o ..\_test\WDT_example.c
7
../_test/WDT_example.c:81: warning: return type of `main' is not `int'
8
msp430-gcc -mmcu=msp430x449 -o20110606.elf _test\WDT_example.o _test\RTC_WDT.o _test\RTC.o
9
_test\RTC_WDT.o: In function `WDT_1sec_wake':
10
(.text+0x2): undefined reference to `WDT_ADLY_1000'
11
_test\RTC_WDT.o: In function `WDT_1sec_wake':
12
(.text+0x4): undefined reference to `WDTCTL'
13
_test\RTC_WDT.o: In function `WDT_1sec_wake':
14
(.text+0x8): undefined reference to `WDTIE'
15
_test\RTC_WDT.o: In function `WDT_1sec_wake':
16
(.text+0xa): undefined reference to `IE1'
17
_test\RTC_WDT.o: In function `WDT_1sec_wake':
18
(.text+0xe): undefined reference to `GIE'
19
_test\RTC_WDT.o: In function `WDT_1sec_wake':
20
(.text+0x10): undefined reference to `SR'
21
Build error occurred, build is stopped
22
Time consumed: 1796  ms.
Moderator Persönliche Seite #2220927
Lesenswert?

J. R. schrieb:

> ../_test/RTC_WDT.S:75: Error: unknown pseudo-op: `.cdecls'
> ../_test/RTC_WDT.S:76: Error: unknown pseudo-op: `.ref'
> ../_test/RTC_WDT.S:77: Error: unknown pseudo-op: `.def'

Ja, die hattest du doch schon rauskommentiert.

Da musst du wohl im MSP430-Assemblerhandbuch nachlesen, wofür die
gut sein sollen, um dann das Pendant vom GNU-Assembler zu finden.
Aber wenn ich mir die so ansehe, braucht man die wohl nicht.

J. R. schrieb:
> bzw

> _test\RTC_WDT.o: In function `WDT_1sec_wake':
> (.text+0x2): undefined reference to `WDT_ADLY_1000'

Das heißt aber, dass der Präprozessor da wohl nach wie vor nicht
drüber gelaufen ist.  Lass ihn mal manuell laufen, indem du das
-c durch ein -E ersetzt und bei -o einen entsprechend anderen
Dateinamen angibst.  Schau dir an, was der Assembler dann gefüttert
bekommt.
OP #2223804
Lesenswert?

Jörg Wunsch schrieb:
> Das heißt aber, dass der Präprozessor da wohl nach wie vor nicht
> drüber gelaufen ist.  Lass ihn mal manuell laufen, indem du das
> -c durch ein -E ersetzt und bei -o einen entsprechend anderen
> Dateinamen angibst.  Schau dir an, was der Assembler dann gefüttert
> bekommt.


Also:
1
msp430-gcc -E -mmcu=msp430x449 -I C:\mspgcc4\msp430\include -o RTC_WDTX.o RTC_WDT.S

liefert als RTC-WDTX.o:
1
# 1 "RTC_WDT.S"
2
# 1 "<built-in>"
3
# 1 "<command line>"
4
# 1 "RTC_WDT.S"
5
;******************************************************************************
6
; .cdecls C,LIST,"msp430.h"
7
; .ref incrementSeconds
8
; .def WDT_1sec_wake
9

10
            .text
11
.global WDT_1sec_wake
12
WDT_1sec_wake:
13
            mov.w #WDT_ADLY_1000, &WDTCTL ; WDT 1 second interrupt
14
            bis.b #WDTIE,&IE1 ; Enable WDT interrupt
15
            bis.b #GIE, SR
16
            ret
17
;-----------------------------------------------------------------------------
18
.global WDT_ISR
19
WDT_ISR:
20
;-----------------------------------------------------------------------------
21
            call #incrementSeconds ; tick one second
22
            reti ;
23
                                            ;
24

25
;-----------------------------------------------------------------------------
26
; Interrupt Vectors Used
27
;-----------------------------------------------------------------------------
28
            .sect WDT_VECTOR ; WDT Vector
29
            .short WDT_ISR ;
30
            .end

sagt Dir das was?

Grüße
OP #2223817
Lesenswert?

Jörg Wunsch schrieb:
>> ../_test/RTC_WDT.S:75: Error: unknown pseudo-op: `.cdecls'

Im
MSP430 Assembly Language Tools v 3.3
User's Guide
http://focus.ti.com/lit/ug/slau131e/slau131e.pdf

steht
"You can use the .cdecls assembler directive to share C headers 
containing declarations and prototypes between C and assembly code. Any 
legal C/C++ can be used in a .cdecls block and the C/C++ declarations 
will cause suitable assembly to be generated automatically, allowing you 
to reference the
C/C++ constructs in assembly code."

Weitere Details dort auf S.73:
The .cdecls options control whether the code is treated as C or C++ 
code; and how the.cdecls block and converted code are presented. Options 
must be separated by commas; they can appear in any order:

C = Treat the code in the .cdecls block as C source code (default).

LIST = Include the converted assembly code in any listing file generated 
for the containing assembly file."

Er holt sich dort also die Definitionen von WDT_ADLY_1000 etc?

Wie kann ich ihm das mithilfe von mps430gcc beibringen?

Grüße
Moderator Persönliche Seite #2224018
Lesenswert?

J. R. schrieb:

> liefert als RTC-WDTX.o:
> [avrasm]# 1 "RTC_WDT.S"
> # 1 "<built-in>"
> # 1 "<command line>"
> # 1 "RTC_WDT.S"

(und dann keine weiteren #-Zeilen)

Das heißt, da ist kein include-File drüber gelaufen.

Weiter oben hast du da noch

#include "msp430x44x.h"
#include "wdt_a.h"

stehen, und letztere Datei sollte die fehlenden Symbole bringen.
OP #2224097
Lesenswert?

Für gcc4 musste ich folgendes einbauen:
1
#include "msp430/wdt_a.h"

doch das Ergebnis:
1
**** Rebuild of configuration Debug for project Versuch ****
2

3
**** Internal Builder is used for build               ****
4
msp430-gcc -c -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC.o ..\_test\RTC.S
5
msp430-gcc -c -mmcu=msp430x449 -IC:\mspgcc4\msp430\include -o_test\RTC_WDT.o ..\_test\RTC_WDT.S
6
C:/mspgcc4/msp430/include/msp430/wdt_a.h: Assembler messages:
7
C:/mspgcc4/msp430/include/msp430/wdt_a.h:23: Error: unknown opcode `sfrw(wdtctl,'
8
Build error occurred, build is stopped
9
Time consumed: 750  ms.

was passiert da?
Die header files der ggc4 sollte der compiler doch verstehen?
OP #2227327
Lesenswert?

hiermit läufts
1
#include "msp430x44x.h"

Egebnis ist also
1
;            .cdecls C,LIST,"msp430.h"
2
#include "msp430x44x.h"
3

4
;            .ref  incrementSeconds
5
;            .def  WDT_1sec_wake
6

7
            .text
8
.global incrementSeconds
9
.global WDT_1sec_wake
10
WDT_1sec_wake:
11
            mov.w   #WDT_ADLY_1000, &WDTCTL ; WDT 1 second interrupt
12
            bis.b   #WDTIE,&IE1             ; Enable WDT interrupt
13
;            bis.b   #GIE,  SR        
14
            bis.b   #GIE,  LPM3      ; LPM3 ist richtig
15
            ret
16
;-----------------------------------------------------------------------------
17
.global WDT_ISR
18
WDT_ISR:
19
;-----------------------------------------------------------------------------
20
            call    #incrementSeconds       ; tick one second
21
            reti                            ;    
22
                                            ;
23

24
;-----------------------------------------------------------------------------
25
;           Interrupt Vectors Used
26
;-----------------------------------------------------------------------------
27
            .sect   WDT_VECTOR               ; WDT Vector
28
            .short  WDT_ISR                  ;
29
            .end

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren