;****************************************************************************
;* Copyright (C) 2004 Dallas Semiconductor Corporation, All Rights Reserved.
;*
;* Permission is hereby granted, free of charge, to any person obtaining a
;* copy of this software and associated documentation files (the "Software"),
;* to deal in the Software without restriction, including without limitation
;* the rights to use, copy, modify, merge, publish, distribute, sublicense,
;* and/or sell copies of the Software, and to permit persons to whom the
;* Software is furnished to do so, subject to the following conditions:
;*
;* The above copyright notice and this permission notice shall be included
;* in all copies or substantial portions of the Software.
;*
;* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
;* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
;* IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
;* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
;* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
;* OTHER DEALINGS IN THE SOFTWARE.
;*
;* Except as contained in this notice, the name of Dallas Semiconductor
;* shall not be used except as stated in the Dallas Semiconductor
;* Branding Policy.
;****************************************************************************
;
; This program demonstrates how to erase a flash memory chip that is not
; supported by the ROM loader of the networked microcontrollers.
;
; To build this program, run
; macro chiperase.asm
; a390 -d -l chiperase.mpp
;
; To execute, load into SRAM and use loader commands 'B0', 'X0'.
;
; Note: When using MTK to load this code, be sure to disable the "Clear Heap"
; option.
;
; The flash memory we want to erase is connected to CE2\, or address 400000h,
; since the ROM uses 2 MB per chip enable.
FLASH_ADDRESS EQU 400000h
; Different flash memories use different addresses to "tickle" flash programming/
; erase operation.
; Erase ST M29W040
; FLASH_TICKLE0 EQU (FLASH_ADDRESS or 555h)
; FLASH_TICKLE1 EQU (FLASH_ADDRESS or 2aah)
; Erase AM29LV200BT
FLASH_TICKLE0 EQU (FLASH_ADDRESS or 0aaah)
FLASH_TICKLE1 EQU (FLASH_ADDRESS or 555h)
org 000000h
start:
; The ROM enables 24 bit mode and disables interrupts.
; No other initialization is necessary.
; Start flash chip erase
; 1st Cycle
mov dptr, #FLASH_TICKLE0
mov a, #0aah
movx @dptr, a
; 2nd Cycle
mov dptr, #FLASH_TICKLE1
mov a, #55h
movx @dptr, a
; 3rd Cycle
mov dptr, #FLASH_TICKLE0
mov a, #80h
movx @dptr, a
; 4th Cycle
mov dptr, #FLASH_TICKLE0
mov a, #0aah
movx @dptr, a
; 5th Cycle
mov dptr, #FLASH_TICKLE1
mov a, #55h
movx @dptr, a
; 6th Cycle
mov dptr, #FLASH_TICKLE0
mov a, #10h
movx @dptr, a
; Wait for operation to complete
mov dptr, #FLASH_ADDRESS
wait:
movx a, @dptr
cjne a, #0ffh, wait
; Reset
mov dptr, #FLASH_ADDRESS
mov a, #0f0h
movx @dptr, a
; Print success message
mov a, #'D'
acall printchar
mov a, #'O'
acall printchar
mov a, #'N'
acall printchar
mov a, #'E'
acall printchar
; Done!
sjmp $
; Serial port 0 is initialized by the loader. Printing
; a character is therefore trivial.
tix bit scon.1
printchar:
jnb tix, $
clr tix
mov sbuf, a
jnb tix, $
ret
end
リスト2. サポートなしのフラッシュのプログラミング(flashprogram.asm)
;****************************************************************************
;* Copyright (C) 2004 Dallas Semiconductor Corporation, All Rights Reserved.
;*
;* Permission is hereby granted, free of charge, to any person obtaining a
;* copy of this software and associated documentation files (the "Software"),
;* to deal in the Software without restriction, including without limitation
;* the rights to use, copy, modify, merge, publish, distribute, sublicense,
;* and/or sell copies of the Software, and to permit persons to whom the
;* Software is furnished to do so, subject to the following conditions:
;*
;* The above copyright notice and this permission notice shall be included
;* in all copies or substantial portions of the Software.
;*
;* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
;* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
;* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
;* IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
;* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
;* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
;* OTHER DEALINGS IN THE SOFTWARE.
;*
;* Except as contained in this notice, the name of Dallas Semiconductor
;* shall not be used except as stated in the Dallas Semiconductor
;* Branding Policy.
;****************************************************************************
;
; This program demonstrates how to erase a flash memory chip that is not
; supported by the ROM loader of the networked microcontrollers.
;
; To build this program, run
; macro flashprogram.asm
; a390 -d -l flashprogram.mpp
;
; To execute, first load the data you wish to program into SRAM memory in
; bank 1 (010000h - 01ffffh). Then, load this code into SRAM and use
; the loader commands 'B0', 'X100'.
;
; Note: When using MTK to load this code, be sure to disable the "Clear Heap"
; option.
;
; The flash memory we want to program is connected to CE2\, or address 400000h,
; since the ROM uses 2 MB per chip enable.
FLASH_ADDRESS EQU 400000h
; Different flash memories use different addresses to "tickle" flash programming/
; erase operation.
; Byte Program AM29LV200BT
FLASH_TICKLE0 EQU (FLASH_ADDRESS or 0aaah)
FLASH_TICKLE1 EQU (FLASH_ADDRESS or 555h)
; Address of programming buffer in SRAM
PROG_BUFFER EQU 010000h
; We want to program a whole 64 kB block
PROG_SIZE EQU 10000h
; This example program uses three datapointers
dps equ 086h
org 000100h
start:
; The ROM enables 24 bit mode and disables interrupts.
; No other initialization is necessary.
; Make sure r2 is in register bank 0
mov psw, #0
; Number of bytes to program
mov r1, #high(PROG_SIZE)
mov r0, #low(PROG_SIZE)
; Source
mov dps, #1
mov dptr, #PROG_BUFFER
; Destination
mov dps, #8
mov dptr, #FLASH_ADDRESS
loop:
; Start flash chip program for this byte
; Get source byte
mov dps, #1
movx a, @dptr
inc dptr
; Save byte we wish to program
mov r2, a
; No need to write the same byte again
; (also prevents writing of 0ffh)
mov dps, #8
movx a, @dptr
xrl a, r2
jz next
; Select dptr0
mov dps, #0
; 1st Cycle
mov dptr, #FLASH_TICKLE0
mov a, #0aah
movx @dptr, a
; 2nd Cycle
mov dptr, #FLASH_TICKLE1
mov a, #55h
movx @dptr, a
; 3rd Cycle
mov dptr, #FLASH_TICKLE0
mov a, #0a0h
movx @dptr, a
; 4th Cycle: Put destination byte
mov dps, #8
mov a, r2
movx @dptr, a
; Wait for operation to complete
wait:
movx a, @dptr
cjne a, 2, wait
next:
mov dps, #8
inc dptr
djnz r0, loop
; Display progress indicator
mov a, #'.'
acall printchar
djnz r1, loop
; Reset
mov dptr, #FLASH_ADDRESS
mov a, #0f0h
movx @dptr, a
; Print success message
mov a, #13
acall printchar
mov a, #10
acall printchar
mov a, #'D'
acall printchar
mov a, #'O'
acall printchar
mov a, #'N'
acall printchar
mov a, #'E'
acall printchar
; Done!
sjmp $
; Serial port 0 is initialized by the loader. Printing
; a character is therefore trivial.
tix bit scon.1
printchar:
jnb tix, $
clr tix
mov sbuf, a
jnb tix, $
ret
end
/* ---------------------------------------------------------------------------
* Copyright (C) 2004 Dallas Semiconductor Corporation, All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL DALLAS SEMICONDUCTOR BE LIABLE FOR ANY CLAIM, DAMAGES
* OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name of Dallas Semiconductor
* shall not be used except as stated in the Dallas Semiconductor
* Branding Policy.
* ---------------------------------------------------------------------------
*/
/*
* Identify - Tries to Identify Flash Memory Make/Model.
* Run from bank 20 (using loader commands B20, X)
*/
#include
#include
void main()
{
unsigned char vendor, device, ce;
puts("DS80C400/DS80C410/DS80C411 Flash Memory Identification");
do {
printf("
Identify flash at which chip enable? ");
do {
putchar(ce = _getkey());
if ((ce < '0') || (ce > '7'))
printf(" 0-7> ");
} while ((ce < '0') || (ce > '7'));
puts("
");
ce -= '0';
ce <<= 5; // 2 MB per chip enable
AP = ce;
#pragma asm
/* Tickle Flash Memory */
mov dptr, #0x5555
mov dpx, ap
mov a, #0xaa
movx @dptr, a
mov dptr, #0xaaaa
mov dpx, ap
mov a, #0x55
movx @dptr, a
/* Read ID Command */
mov dptr, #0x5555
mov dpx, ap
mov a, #0x90
movx @dptr, a
/* Read Manufacturer ID */
mov dptr, #0
mov dpx, ap
movx a, @dptr
#pragma endasm
vendor = ACC;
#pragma asm
/* Reset Flash */
mov dptr, #0
mov dpx, ap
mov a, #0xf0
movx @dptr, a
mov a, #0xff
movx @dptr, a
#pragma endasm
#pragma asm
/* Tickle Flash Memory */
mov dptr, #0x5555
mov dpx, ap
mov a, #0xaa
movx @dptr, a
mov dptr, #0xaaaa
mov dpx, ap
mov a, #0x55
movx @dptr, a
/* Read ID Command */
mov dptr, #0x5555
mov dpx, ap
mov a, #0x90
movx @dptr, a
/* Read Manufacturer ID */
mov dptr, #0x01
mov dpx, ap
movx a, @dptr
#pragma endasm
device = ACC;
#pragma asm
/* Reset Flash */
mov dptr, #0
mov dpx, ap
mov a, #0xf0
movx @dptr, a
mov a, #0xff
movx @dptr, a
#pragma endasm
printf("Flash memory at CE%bu: Vendor ID %02bX, Device ID %02bX.
--> ", ce >> 5, vendor, device);
switch (vendor) {
case 0x01: printf("Spansion AM");
switch (device) {
case 0x37: puts("29LV008 Top Boot"); break;
case 0x38: puts("29LV081"); break;
case 0x3b: puts("29LV200 Top Boot"); break;
case 0x3e: puts("29LV008 Bottom Boot"); break;
case 0x49: puts("29LV160 Bottom Boot"); break;
case 0x4c: puts("29LV116 Bottom Boot"); break;
case 0x4f: puts("29LV040"); break;
case 0x5b: puts("29LV800 Bottom Boot"); break;
case 0xa3: puts("29LV033"); break;
case 0xb5: puts("29LV004 Top Boot"); break;
case 0xb6: puts("29LV004 Bottom Boot"); break;
case 0xb9: puts("29LV400 Top Boot"); break;
case 0xba: puts("29LV400 Bottom Boot"); break;
case 0xbf: puts("29LV200 Bottom Boot"); break;
case 0xc4: puts("29LV160 Top Boot"); break;
case 0xc7: puts("29LV116 Top Boot"); break;
case 0xc8: puts("29LV017"); break;
case 0xda: puts("29LV800 Top Boot"); break;
case 0xf6: puts("29LV320 Top Boot"); break;
case 0xf9: puts("29LV320 Bottom Boot"); break;
default: puts(" ????"); break;
}
break;
case 0x1f: printf("Atmel AT");
switch (device) {
case 0x21: puts("49BV/LV008 T"); break;
case 0x22: puts("49BV/LV008"); break;
case 0xeb: puts("49LL080"); break;
default: puts(" ????"); break;
}
break;
case 0x20: printf("ST M");
switch (device) {
case 0x5b: puts("29W800 Bottom Boot"); break;
case 0xd2: puts("29W008 Top Boot"); break;
case 0xd7: puts("29W800 Top Boot"); break;
case 0xdc: puts("29W008 Bottom Boot"); break;
case 0xe3: puts("29W040"); break;
case 0xea: puts("29W004 Top Boot"); break;
case 0xeb: puts("29W004 Bottom Boot"); break;
default: puts(" ????"); break;
}
break;
case 0x89: printf("Intel or Sharp LH or "); // fall through
case 0x2c: printf("Micron MT");
switch (device) {
case 0x16: puts("28F320J3"); break;
case 0x70: puts("28F004B3/28F400B3 Top Boot"); break;
case 0x71: puts("28F004B3/28F400B3 Bottom Boot"); break;
case 0x9c: puts("28F008B3/28F800B3 Top Boot"); break;
case 0x9d: puts("28F008B3/28F800B3 Bottom Boot"); break;
case 0xaa: puts("28F016SC"); break;
default: puts(" ????"); break;
}
break;
case 0xbf: printf("SST SST");
switch (device) {
case 0xc8: puts("39VF1681"); break;
case 0xc9: puts("39VF1682"); break;
case 0xd4: puts("39LF/VF512"); break;
case 0xd5: puts("39LF/VF010"); break;
case 0xd6: puts("39LF/VF020"); break;
case 0xd7: puts("39LF/VF040"); break;
case 0xd8: puts("39LF/VF080"); break;
default: puts(" ????"); break;
}
break;
case 0x02:
case 0xc2: printf("Macronix MX");
switch (device) {
case 0x38: puts("29LV081"); break;
case 0xa3: puts("29LV033"); break;
case 0xc8: puts("29LV017"); break;
default: puts(" ????"); break;
}
break;
case 0xda: printf("Winbond W");
switch (device) {
case 0xd6: puts("39L040"); break;
default: puts(" ????"); break;
}
break;
default: puts("Unknown vendor/unknown device");
break;
}
} while (1);
}