This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Msp430 Addressing Modes

 Hi guys I'm trying to do this question for an assignment using the msp430 -ez430-f2013 but the value at  the memory address I'm  moving to stays at 0xFFFFh.The code I'm using seems correct(at the bottom of this post). Is there something I'm missing ?

Q1.) Using assembly language at the start (beginning) of your code, initialize R6 to 0010h.  Then, store the value of 0015h into the location

010A6h in memory using an appropriate addressing mode.  Then, relocate this value again using an appropriate addressing mode, retrieve the value from location 010A6h in code and ADD that value to register R6. Use this value as half the number of times to blink (flash) the LED.



#include <msp430.h>
;-------------------------------------------------------------------------------
            ORG     0F800h                  ; Program Reset
;-------------------------------------------------------------------------------

RESET       mov.w   #0280h,SP               ; Initialize stackpointer
StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
SetupP1     bis.b   #001h,&P1DIR
; P1.0 outputall

Initialize mov.w #0010h,R6
mov.w #010A6h,R7
Move mov.w #0015h,0h(R7)
Moveagain mov.w @R7+,8(R7)
add.w 8(R7),R6


L2 dec.w  R6
                
Mainloop    xor.b   #001h,&P1OUT            ; Toggle P1.0
Wait        mov.w   #02,R15             ; Delay to R15
L1          dec.w   R15                     ; Decrement R15
            jnz     L1                      ; Delay over?
            cmp.w   #000,R6
            jne L2

            cmp.w   #000,R6
            jge Stop
Stop  bis.w #LPM0|GIE,SR ; Enable ints and low power mode 0
       jmp Stop
              ; Again
 ;-------------------------------------------------------------------------------
;           Interrupt Vectors
;-------------------------------------------------------------------------------
            ORG     0FFFEh                  ; MSP430 RESET Vector
            DW      RESET                   ;
            END

  • memory location 0x10a6 is in info memory, which is flash memory. Flash memory is read only. To write to it, a specific procedure has to be followed, and writing has some limitation.
    If the location contains 0xFFFF, you have to configure the flash controller into write mode, write to the location, then switch off the flash controller again.
    If the address contains a value other than 0xffff, then you need to erase the whole segment (64 to 512 bytes, depending on MSP and flash area) before you can write to it again.

    Search the board for related threads (flash write), and also read the users guide and datasheet regarding flash writing and flash controller.

  • Jens-Michael Gross said:
    memory location 0x10a6 is in info memory, which is flash memory.

    To the OP: I would be asking the instructor if s/he meant for the class to be figuring out how to erase/program flash or if s/he used a wrong address (or didn't update instructions from a previous class that used different hardware).

    Or it could be that s/he just wanted to see how you would write the assembly code and didn't necessarily intend for it to run on an actual chip.

**Attention** This is a public forum