Hi,
I have found my notes contain copy/paste mistakes.
I am not sure what are you looking at so more detailed comments. Moreover, I suppose the DFLASH is in erased status before it is written.
Moreover, the question is how the RAM content is refreshed in your memory window. You should also check the setup lime it is done for DFLASH.
The address 0x2100 is selected by compiler so the array is placed:
Buffer[0] is at address 0x2100,0x2101 of a local address space
Buffer[1] is at address 0x2102,0x2103
Buffer[2] is at address 0x2104,0x2105
Buffer[3] is at address 0x2106,0x2106
Finally, it is good to understand local and global address space. The RAM 0x2100 is in local address space 0x2100 and in the global address space 0x0F_E100. Si memory map in attachment.
... and be careful when you show address space ... extension 'G or 'L. For example 0FE100'G and 2100'L represents the same address from different views.
.... does no exist
.... the variable "buffer" in a local address space
... the variable "buffer" in a global address space
better comments of the original asm code..
;---------------------------
;err = DFLASH_Program(0x0000, &buffer[0], 4); //write 4 words to D Flash address 0x10_0000
; GPAGE (0x10_.... ) is not used in the Addr variable because it is directly used in the DFLASH_Program routine
MOVW #$0000,Addr ; address to be written 0x(10)0000~0x(10)0007
MOVB #4,Cnt ; number of words to be written
;for example data to be written into DFLASH are 0x0123, 0x4567, 0x89AB, 0xCDEF
; written global DFLASH address is 0x10_0000’G … for data visualization in a debugger memory
; window“ ’G ” must be added into memory address
LDX #Buffer ; Load the base address of the array into X register, the base address
; is selected by compiler if you do not set exact address
LDD #$0123 ; Load the hexadecimal value 0x0123 into D register
STD 0,X ; Store the value at the 0th position of the array; Buffer[0] = 0x0123
LDD #$4567 ; Load the value 0x4567 into D register
STD 2,X ; Store the value at the 1st position of the array; Buffer[1] = 0x4567
LDD #$89AB ; Load the value 0x89AB into D register
STD 4,X ; Store the value at the 2nd position of the array; Buffer[2] = 0x89AB
LDD #$CDEF ; Load the value 0xCDEF into D register
STD 6,X ; Store the value at the 3rd position of the array; Buffer[3] = 0xCDEF
CALL DFLASH_Program ; note there is a status of verification in the Err variable after execution of this command
;---------------------------
;err = DFLASH_Program(0x0008, &buffer[0], 4); //write 4 words to eeprom address 0x0000
;… at this place you should check whether Err value is OK to be sure entire write process has
; finished correctly. I am not doing it in this example.
;---------------------------
; write another set of data to a 8 bites higher address of the DFLASH
; written global DFLASH address is 0x10_0008’G
MOVW #$0008,Addr ; address to be written 0x(10)0008~0x(10)000F
MOVB #4,Cnt ; number of words to be written
;for example data to be written into DFLASH are 0xDEAD,0xBEEF,0xC0DE,0xCAFE
LDX #Buffer ; Load the base address of the array into X register, the base address
; is selected by compiler if you do not set exact address
LDD #$DEAD ; Load the hexadecimal value 0xDEAD into D register
STD 0,X ; Store the value at the 0th position of the array; Buffer[0] = 0x0123
LDD #$BEEF ; Load the value 0xBEEF into D register
STD 2,X ; Store the value at the 1st position of the array; Buffer[1] = 0x4567
LDD #$C0DE ; Load the value 0XC0DE into D register
STD 4,X ; Store the value at the 2nd position of the array; Buffer[2] = 0x89AB
LDD #$CAFE ; Load the value 0xCAFE into D register
STD 6,X ; Store the value at the 3rd position of the array; Buffer[3] = 0xCDEF
CALL DFLASH_Program ; note there is a status of verifiction in the Err variable after execution of this command
;---------------------------
;err = DFLASH_Program(0x0008, &buffer[0], 4); //write 4 words to eeprom address 0x0000
;… at this place you should check whether Err value is OK to be sure entire write process has
; finished correctly. I am not doing it in this example.
;---------------------------
Best regards,
Ladislav