Assembly Language help (Beginner)

Thread Starter

jean28

Joined Sep 5, 2012
76
Hey guys. I am taking a Microprocessors course and I have a few labs that I have to do with my microcontrollers.

I am using the TI MSP430 and the IAR Embedded Workbench IDE for programming it. The manual that I am using says that I should save the code as .asm file, but for some reason whenever I try to do it, it doesn't work exactly as it should and when I run the program I get an error.

Could anyone give me an idea of what I am doing wrong?

Here is the code:

Rich (BB code):
#include       msp430.h
;--------------------------------------------------------------------------
            ORG      0f800h    ; Program Start
;--------------------------------------------------------------------------
RESET       mov      #0280h,SP                   ;  Initialize stackpointer
StopWDT     mov      #WDTPW+WDTHOLD,&WDTCTL      ;   StopWDT
SetupP1     bis.b    #1,&P1DIR                   ; P1.0 as output
Main        xor.b    #1,&P1OUT                   ; Toggle P1.0
Wait        mov      #50000,R15                  ; Delay to R15
L1          dec      R15                         ; Decrement R15
	    jnz      L1                          ; Delay over?
	    jmp      Main                        ; Again?
;--------------------------------------------------------------------------
;		Interrupt Vectors
;--------------------------------------------------------------------------
            ORG      0FFFEh                      ; MSP430 RESET Vector
	    DW       RESET                       ;
	    END

Here is the error I get:

Building configuration: Example1 - Debug
Updating build tree...
Try.asm
Error[3]: Invalid #include file name C:\Users\Jean\Desktop\Coding Files\Assembly Language\EXP1\Try.asm 1
Error while running Assembler

Total number of errors: 1
Total number of warnings: 0
 

MMcLaren

Joined Feb 14, 2010
861
Not sure about IAR but CCS (Code Composer Studio) uses the same header files for both C and assembly language programs.

Here's the front end from a CCS assembly language program for an MSP430G2231 which was gleaned from the TI example programs for the '2231 and CCS. Aren't there examples from TI for your processor and IAR?


Regards, Mike

Rich (BB code):
*******************************************************************************
*******************************************************************************

        .cdecls C,LIST, "msp430g2231.h"

        .bss    count, 1
        .bss    flags, 1

;------------------------------------------------------------------------------
        .text                           ; Progam Start
        .global	_main
;------------------------------------------------------------------------------
TxPin	.equ	2

_main
        mov.w   #0280h,SP               ; Init stackpointer (top of RAM)
        mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT

        clr.b   &DCOCTL                 ; DCO calibrated 1-MHz settings
        mov.b   &CALBC1_1MHZ,&BCSCTL1   ; 
        mov.b   &CALDCO_1MHZ,&DCOCTL    ;

        mov.b   #BIT6+BIT1+BIT0,&P1DIR  ; P1.6 & P1.0 outputs
        mov.b   #BIT0,&P1OUT            ;
 

Thread Starter

jean28

Joined Sep 5, 2012
76
Not sure about IAR but CCS (Code Composer Studio) uses the same header files for both C and assembly language programs.

Here's the front end from a CCS assembly language program for an MSP430G2231 which was gleaned from the TI example programs for the '2231 and CCS. Aren't there examples from TI for your processor and IAR?


Regards, Mike

Rich (BB code):
*******************************************************************************
*******************************************************************************

        .cdecls C,LIST, "msp430g2231.h"

        .bss    count, 1
        .bss    flags, 1

;------------------------------------------------------------------------------
        .text                           ; Progam Start
        .global	_main
;------------------------------------------------------------------------------
TxPin	.equ	2

_main
        mov.w   #0280h,SP               ; Init stackpointer (top of RAM)
        mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT

        clr.b   &DCOCTL                 ; DCO calibrated 1-MHz settings
        mov.b   &CALBC1_1MHZ,&BCSCTL1   ; 
        mov.b   &CALDCO_1MHZ,&DCOCTL    ;

        mov.b   #BIT6+BIT1+BIT0,&P1DIR  ; P1.6 & P1.0 outputs
        mov.b   #BIT0,&P1OUT            ;
I am using a special manual from my class so I wouldn't really know. I'll try this code out.
I can provide an answer later when I find the time.
I would really appreciate your help. Thank you very much.
 

MrChips

Joined Oct 2, 2009
30,821
Start from scratch.

Open IAR Embedded Workbench.

Select menu Project->Create New Project...
Select double click on "asm", select "asm", click OK.
Enter name of Project File.

Select menu Project->Options...->Target Device-> select your mcu chip
Select from same dialog Debugger-> Setup Driver->FET Debugger OK

You should see an asm template called "asm.s43" in the editor window.
Use this template as your starting point.
 

Thread Starter

jean28

Joined Sep 5, 2012
76
Start from scratch.

Open IAR Embedded Workbench.

Select menu Project->Create New Project...
Select double click on "asm", select "asm", click OK.
Enter name of Project File.

Select menu Project->Options...->Target Device-> select your mcu chip
Select from same dialog Debugger-> Setup Driver->FET Debugger OK

You should see an asm template called "asm.s43" in the editor window.
Use this template as your starting point.
Do I write my code over the code in asm.s43? My manual gives those exact same steps but it tells me to close asm.s43 and to create a new file.
 

MrChips

Joined Oct 2, 2009
30,821
You can do either. We know that the template supplied by IAR works.
Rather than throwing it out completely, compare both files and see what is common.

Understand what each statement does. If you don't know, don't be afraid to ask.
Find out what is essential and what isn't.
 

MrChips

Joined Oct 2, 2009
30,821
Here is your code:

Rich (BB code):
#include       msp430.h
;--------------------------------------------------------------------------
            ORG      0f800h    ; Program Start
;--------------------------------------------------------------------------
RESET       mov      #0280h,SP                   ;  Initialize stackpointer
StopWDT     mov      #WDTPW+WDTHOLD,&WDTCTL      ;   StopWDT
SetupP1     bis.b    #1,&P1DIR                   ; P1.0 as output
Main        xor.b    #1,&P1OUT                   ; Toggle P1.0
Wait        mov      #50000,R15                  ; Delay to R15
L1          dec      R15                         ; Decrement R15
        jnz      L1                          ; Delay over?
        jmp      Main                        ; Again?
;--------------------------------------------------------------------------
;        Interrupt Vectors
;--------------------------------------------------------------------------
            ORG      0FFFEh                      ; MSP430 RESET Vector
        DW       RESET                       ;
        END
Here is the IAR code:

Rich (BB code):
    #include "msp430.h"              ; #define controlled include file

        NAME    main                    ; module name

        PUBLIC  main                    ; make the main label vissible
                                        ; outside this module
        ORG     0FFFEh
        DC16    init                    ; set reset vector to 'init' label

        RSEG    CSTACK                  ; pre-declaration of segment
        RSEG    CODE                    ; place program in 'CODE' segment

init:   MOV     #SFE(CSTACK), SP        ; set up stack

main:   NOP                             ; main program
        MOV.W   #WDTPW+WDTHOLD,&WDTCTL  ; Stop watchdog timer
        JMP $                           ; jump to current location '$'
                                        ; (endless loop)
        END
 
Top