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.

Write to INFO Segment Fails when MCLK is 1MHz

Other Parts Discussed in Thread: MSP430F2012

Hello Forum,

From the past few days i've been trying to write 10 bytes to INFO seg D or C, but it fails.

MCU is MSP430F2012, In my code ( which i've modified from ti Flash write code example), i have stored some 10 bytes constants at the end of program (data table).

My code tries to copy these 10 bytes to INFO seg D but it fails.

I'm using calibrated 1MHz DCO as clk source,

surprisingly, the flash write is successful when i change the MCLK to higher than 1MHZ, like 8, 12, or 16 MHZ

But with 1MHZ it fails, i 've tried matching the Flash timing Generator speed using FN bits but no luck.

Here's my code:

;--------------------------------------------------------------------------------------------------------------------------------------------

#define  VALUE  R4

#include  "msp430f2012.h"

;-------------------------------------------------------------------------------
            ORG     0F800h                  ; Program Reset
;-------------------------------------------------------------------------------

RESET       mov.w   #0280h,SP               ; Initialize stackpointer

StopWDT     mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT

CheckCal    cmp.b   #0FFh,&CALBC1_1MHZ      ; Calibration constants erased?
            
            jeq     Trap

            cmp.b   #0FFh,&CALDCO_1MHZ

            jne     Load  

Trap        jmp     $                       ; Trap CPU!!

Load        mov.b   &CALBC1_1MHZ,&BCSCTL1   ; Set DCO to 1MHz

            mov.b   &CALDCO_1MHZ,&DCOCTL

            clr.b   VALUE                   ; value = value to write to flash
                                            ;                                                      
Mainloop    call    #Write_SegD             ;


    HERE:   jmp $
                                            ;
;-------------------------------------------------------------------------------
Write_SegD   ;Input = value.
;-------------------------------------------------------------------------------
           
            mov.w  #01000h,R5
              
Timing      mov.w  #FWKEY+FSSEL_2+FN1,&FCTL2  ;

Erase_SegD  mov.w  #FWKEY,&FCTL3           ; Lock = 0

            mov.w  #FWKEY+ERASE,&FCTL1     ; Erase bit = 1, allow interrupts

            mov.w  #0,&01000h              ; Dummy write to SegD to erase
                     
               
                     
Prog_SegD   mov.w  #FWKEY+WRT,&FCTL1       ; Write bit = 1, block interrupts             
 
            MOV.W #01000h,R5

            MOV.W #PH_NUM,R8

 GET_HERE:  MOV.B @R8,VALUE

            CMP.B #0AAH,VALUE

            JEQ DONE

            MOV.B VALUE,0(R5)
    
            
            INC.W R5               ; INCRMENT DESTINATION ADDRESS

            INC.W R8               ; INCRMENT POINTER

            JMP GET_HERE
     

     DONE:  MOV.W #FWKEY+LOCK,&FCTL3       ; Lock = 1
             
            RET
           
;-------------------------------------------------------------------------------

PH_NUM:

DB 4H
DB 0H
DB 2H
DB 7H
DB 1H
DB 1H
DB 4H
DB 4H
DB 8H
DB 3H
DB 0AAH


;-------------------------------------------------------------------------------
;           Interrupt Vectors
;-------------------------------------------------------------------------------
            ORG     0FFFEh                  ; MSP430 RESET Vector
            DW      RESET                   ;
           

END

;-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Here's the FLASH dump when i read the flash using Elptronic LITE FET-PRO s/w:

=== Information Memory Segments  0x1000 - 0x10FF ======


0x1000: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1010: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1020: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1030: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1040: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1050: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1060: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1070: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1080: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1090: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10A0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10B0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10C0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10D0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10E0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10F0: FF FF FF FF FF FF 8C 8A   D0 8E 5E 8E 47 8D 93 86 | ..........^.G...

========== Main Memory Segments  0xF800 - 0xFFFF ======


0xF800: 31 40 80 02 B2 40 80 5A   20 01 F2 93 FF 10 03 24 | 1@...@.Z ......$
0xF810: F2 93 FE 10 01 20 FF 3F   D2 42 FF 10 57 00 D2 42 | ..... .?.B..W..B
0xF820: FE 10 56 00 44 43 B0 12   2C F8 FF 3F 35 40 00 10 | ..V.DC..,..?5@..
0xF830: B2 40 82 A5 2A 01 B2 40   00 A5 2C 01 B2 40 02 A5 | .@..*..@..,..@..
0xF840: 28 01 82 43 00 10 B2 40   40 A5 28 01 35 40 00 10 | (..C...@@.(.5@..
0xF850: 38 40 6E F8 64 48 74 90   AA 00 05 24 C5 44 00 00 | 8@n.dHt....$.D..
0xF860: 15 53 18 53 F7 3F B2 40   10 A5 2C 01 30 41 04 00 | .S.S.?.@..,.0A..
0xF870: 02 07 01 01 04 04 08 03   AA FF FF FF FF FF FF FF | ................
0xF880: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0xF890: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | .......

And here's the dump when i increase the MCLK freq from 1MHZ to 8MHZ :

=== Information Memory Segments  0x1000 - 0x10FF ======


0x1000: 04 00 02 07 01 01 04 04   08 03 FF FF FF FF FF FF | ................
0x1010: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1020: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1030: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1040: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1050: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1060: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1070: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1080: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x1090: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10A0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10B0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10C0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10D0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10E0: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................
0x10F0: FF FF FF FF FF FF 8C 8A   D0 8E 5E 8E 47 8D 93 86 | ..........^.G...

========== Main Memory Segments  0xF800 - 0xFFFF ======


0xF800: 31 40 80 02 B2 40 80 5A   20 01 F2 93 FF 10 03 24 | 1@...@.Z ......$
0xF810: F2 93 FE 10 01 20 FF 3F   D2 42 FD 10 57 00 D2 42 | ..... .?.B..W..B
0xF820: FC 10 56 00 44 43 B0 12   2C F8 FF 3F 35 40 00 10 | ..V.DC..,..?5@..
0xF830: B2 40 82 A5 2A 01 B2 40   00 A5 2C 01 B2 40 02 A5 | .@..*..@..,..@..
0xF840: 28 01 82 43 00 10 B2 40   40 A5 28 01 35 40 00 10 | (..C...@@.(.5@..
0xF850: 38 40 6E F8 64 48 74 90   AA 00 05 24 C5 44 00 00 | 8@n.dHt....$.D..
0xF860: 15 53 18 53 F7 3F B2 40   10 A5 2C 01 30 41 04 00 | .S.S.?.@..,.0A..
0xF870: 02 07 01 01 04 04 08 03   AA FF FF FF FF FF FF FF | ................
0xF880: FF FF FF FF FF FF FF FF   FF FF FF FF FF FF FF FF | ................

I've check with 3 other brand new F2012s but the result is same.

In the actual application i'll be using 1MHZ clk and just to write to flash i don't want to go for higher clk.

Any help in this regard is much appreciated,

Thanks,

Nura

  • The CheckCal-Trap-Load part of you code is ineffective. (I know lots of people use similar bad self-perpetuation sample code like this.)

    What is the actual value of &CALBC1_1MHZ stored in Info-D of you chip?

  • old_cow_yellow said:
    The CheckCal-Trap-Load part of you code is ineffective.

    Actually i never use this "trap" in any of my own codes but it was in the Flash write example code which TI provided.

    Calibration values are in INFO SEG A and are not erased.( as shown in the above dump/s)

    Yesterday, instead of using Elptronic s/w i used IAR with "debug w/o downloading " option and during debugging mcu actually was writing those 10 bytes at specified locations. but when i tried reading the Flash with Elptronic "READ/COPY" option it showed all FFs.

    Now, i guess by using higher clock speed (8MHZ and above) the SBW communication/emulation/transfer runs much faster than when using slower clock like 1MHZ.

    That explains why those 10 bytes showed up when using 8MHZ clock but not when using 1MHz clock (reading using Elptronic s/w).

    Finally i confirm flash write is/was successful while using 1Mhz clock, but the problem was with Elptronic s/w not showing them when using slower clock.

    Nura

  • Nura said:
    ... Now, i guess by using higher clock speed (8MHZ and above) the SBW communication/emulation/transfer runs much faster than when using slower clock like 1MHZ.

    That explains why those 10 bytes showed up when using 8MHZ clock but not when using 1MHz clock (reading using Elptronic s/w). ...

    I do not think so.

**Attention** This is a public forum