FlashBadBlockProcess.lst
上传用户:xhjmsc
上传日期:2019-09-13
资源大小:389k
文件大小:38k
- ##############################################################################
- # #
- # IAR MSP430 C/EC++ Compiler V2.10A/W32 23/Apr/2007 18:04:11 #
- # Copyright 1996-2003 IAR Systems. All rights reserved. #
- # #
- # __rt_version = 1 #
- # __double_size = 32 #
- # __reg_r4 = free #
- # __reg_r5 = free #
- # __pic = no #
- # Source file = E:projectFaxProgramVson_Bryan_Fax_Conexant_070423 #
- # filesFlashBadBlockProcess.c #
- # Command line = -I "C:Program FilesIAR SystemsEmbedded Workbench #
- # 3.2430INC" -I "C:Program FilesIAR #
- # SystemsEmbedded Workbench 3.2430INCCLIB" -lCN #
- # E:projectFaxProgramVson_Bryan_Fax_Conexant_070423 #
- # DebugList -lA E:projectFaxProgramVson_Bryan_Fax_ #
- # Conexant_070423DebugList -o #
- # E:projectFaxProgramVson_Bryan_Fax_Conexant_070423 #
- # DebugObj -z2 --no_cse --no_unroll --no_inline #
- # --no_code_motion --debug -e #
- # E:projectFaxProgramVson_Bryan_Fax_Conexant_070423 #
- # filesFlashBadBlockProcess.c #
- # List file = E:projectFaxProgramVson_Bryan_Fax_Conexant_070423 #
- # DebugListFlashBadBlockProcess.lst #
- # Object file = E:projectFaxProgramVson_Bryan_Fax_Conexant_070423 #
- # DebugObjFlashBadBlockProcess.r43 #
- # #
- # #
- ##############################################################################
- E:projectFaxProgramVson_Bryan_Fax_Conexant_070423filesFlashBadBlockProcess.c
- 1 /***************************************
- 2 Program: FlashBadBlockProcess
- 3 Author: Bryan Cai
- 4 Date: 2006.12.02
- 5 ***************************************/
- 6
- 7 #include "includeH.h"
- In segment DATA16_AN, at 0x28
- unsigned char const volatile __data P2IN
- P2IN:
- 000000 DS8 1
- In segment DATA16_AN, at 0x29
- unsigned char volatile __data P2OUT
- P2OUT:
- 000000 DS8 1
- In segment DATA16_AN, at 0x30
- unsigned char const volatile __data P5IN
- P5IN:
- 000000 DS8 1
- In segment DATA16_AN, at 0x32
- unsigned char volatile __data P5DIR
- P5DIR:
- 000000 DS8 1
- 8
- In segment CODE, align 2, keep-with-next
- 9 void CheckInvalidBlock(void)
- CheckInvalidBlock:
- 10 {
- 000000 0A12 PUSH.W R10
- 000002 0B12 PUSH.W R11
- 000004 0812 PUSH.W R8
- 000006 0912 PUSH.W R9
- 000008 0612 PUSH.W R6
- 00000A 0712 PUSH.W R7
- 00000C 0412 PUSH.W R4
- 00000E 0512 PUSH.W R5
- 000010 2183 SUB.W #0x2, SP
- 11 unsigned int wPageAddress=0, wBlockAddress=1,
- 000012 0743 MOV.W #0x0, R7
- 000014 1A43 MOV.W #0x1, R10
- 12 wByteCnt=0;
- 000016 0B43 MOV.W #0x0, R11
- 13 unsigned char ucFlashWriteData=0,ucFlashReadData=0,
- 000018 4443 MOV.B #0x0, R4
- 00001A 4543 MOV.B #0x0, R5
- 14 ucRxIndex=0,ucGeneralCnt=0,
- 00001C 4843 MOV.B #0x0, R8
- 00001E C1430000 MOV.B #0x0, 0x0(SP)
- 15 ucBadBlockCnt=0,ucRxBufFullCnt=0;
- 000022 4943 MOV.B #0x0, R9
- 000024 4643 MOV.B #0x0, R6
- 16
- 17 ZERO_ADDRESS();
- 000026 B012.... CALL #ZERO_ADDRESS
- 18 ERASE_ONE_BLOCK(); // Erase block 0
- 00002A B012.... CALL #ERASE_ONE_BLOCK
- 19 for (wBlockAddress=1;wBlockAddress<1024;wBlockAddress++)
- 00002E 1A43 MOV.W #0x1, R10
- ??CheckInvalidBlock_5:
- 000030 3A900004 CMP.W #0x400, R10
- 000034 DC2C JC ??CheckInvalidBlock_6
- 20 {
- 21 wPageAddress=wBlockAddress<<6;
- 000036 0C4A MOV.W R10, R12
- 000038 B012.... CALL #?ShiftLeft16_6
- 00003C 074C MOV.W R12, R7
- 22 ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- 00003E C247.... MOV.B R7, &ROW_ADDRESS_LOW
- 23 ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- 000042 0E47 MOV.W R7, R14
- 000044 8E10 SWPB R14
- 000046 3EF0FF00 AND.W #0xff, R14
- 00004A C24E.... MOV.B R14, &ROW_ADDRESS_HIGH
- 24 ERASE_ONE_BLOCK();
- 00004E B012.... CALL #ERASE_ONE_BLOCK
- 25 for (ucGeneralCnt=0;ucGeneralCnt<64;ucGeneralCnt++,wPageAddress++)
- 000052 C1430000 MOV.B #0x0, 0x0(SP)
- ??CheckInvalidBlock_4:
- 000056 F19040000000 CMP.B #0x40, 0x0(SP)
- 00005C C52C JC ??CheckInvalidBlock_7
- 26 {
- 27 ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- 00005E C247.... MOV.B R7, &ROW_ADDRESS_LOW
- 28 ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- 000062 0E47 MOV.W R7, R14
- 000064 8E10 SWPB R14
- 000066 3EF0FF00 AND.W #0xff, R14
- 00006A C24E.... MOV.B R14, &ROW_ADDRESS_HIGH
- 29 ucFlashWriteData=0xff;
- 00006E 7443 MOV.B #0xff, R4
- 30 //PROGRAM_ONE_PAGE(ucFlashWriteData);
- 31 //COMMAND
- 32 COMMAND_VAL=0x00; //#0X00
- 000070 C243.... MOV.B #0x0, &COMMAND_VAL
- 33 COMMAND_LATCH_INTO();
- 000074 B012.... CALL #COMMAND_LATCH_INTO
- 34 //ADDRESS
- 35 ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
- 000078 D242........ MOV.B &COLUMN_ADDRESS_LOW, &ADDRESS_VALUE
- 36 ADDRESS_LATCH_INTO();
- 00007E B012.... CALL #ADDRESS_LATCH_INTO
- 37
- 38 ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
- 000082 D242........ MOV.B &COLUMN_ADDRESS_HIGH, &ADDRESS_VALUE
- 39 ADDRESS_LATCH_INTO();
- 000088 B012.... CALL #ADDRESS_LATCH_INTO
- 40
- 41 ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
- 00008C D242........ MOV.B &ROW_ADDRESS_LOW, &ADDRESS_VALUE
- 42 ADDRESS_LATCH_INTO();
- 000092 B012.... CALL #ADDRESS_LATCH_INTO
- 43
- 44 ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
- 000096 D242........ MOV.B &ROW_ADDRESS_HIGH, &ADDRESS_VALUE
- 45 ADDRESS_LATCH_INTO();
- 00009C B012.... CALL #ADDRESS_LATCH_INTO
- 46 FLASH_CON_PORT_OUT &= ~ALE;
- 0000A0 E2C32900 BIC.B #0x2, &0x29
- 47
- 48 COMMAND_VAL=0X30;
- 0000A4 F2403000.... MOV.B #0x30, &COMMAND_VAL
- 49 COMMAND_LATCH_INTO();
- 0000AA B012.... CALL #COMMAND_LATCH_INTO
- 50 //ATcmdDelay();
- 51 //for(wGeneralCnt=0;wGeneralCnt<0xff;wGeneralCnt++); //delay
- 52 while((FLASH_CON_PORT_IN & RB)==0);
- ??CheckInvalidBlock_0:
- 0000AE F2B020002800 BIT.B #0x20, &0x28
- 0000B4 FC2B JNC ??CheckInvalidBlock_0
- 53 DATA_PORT_IN_INITIAL;
- 0000B6 C2433200 MOV.B #0x0, &0x32
- 54 for(wByteCnt=0;wByteCnt<2112;wByteCnt++)
- 0000BA 0B43 MOV.W #0x0, R11
- ??CheckInvalidBlock_1:
- 0000BC 3B904008 CMP.W #0x840, R11
- 0000C0 2F2C JC ??CheckInvalidBlock_8
- 55 {
- 56 FLASH_CON_PORT_OUT &=~ RE; //RE IS LOW,ENABLE READ DATA
- 0000C2 F2C010002900 BIC.B #0x10, &0x29
- 57 ucFlashReadData=DATA_PORT_IN;
- 0000C8 55423000 MOV.B &0x30, R5
- 58 FLASH_CON_PORT_OUT |= RE;
- 0000CC F2D010002900 BIS.B #0x10, &0x29
- 59 if (ucFlashReadData!=ucFlashWriteData)
- 0000D2 4594 CMP.B R4, R5
- 0000D4 2324 JEQ ??CheckInvalidBlock_9
- 60 {
- 61
- 62 if (ucBadBlockCnt++<128)
- 0000D6 4E49 MOV.B R9, R14
- 0000D8 5943 MOV.B #0x1, R9
- 0000DA 495E ADD.B R14, R9
- 0000DC 7E908000 CMP.B #0x80, R14
- 0000E0 112C JC ??CheckInvalidBlock_10
- 63 {
- 64 aucUartRxBuf[ucRxIndex++]=wBlockAddress & 0xff; //low 8 byte
- 0000E2 4E48 MOV.B R8, R14
- 0000E4 3EF0FF00 AND.W #0xff, R14
- 0000E8 CE4A.... MOV.B R10, aucUartRxBuf(R14)
- 0000EC 5853 ADD.B #0x1, R8
- 65 aucUartRxBuf[ucRxIndex++]=(wBlockAddress>>8) & 0xff; //high 8 byte
- 0000EE 4F48 MOV.B R8, R15
- 0000F0 3FF0FF00 AND.W #0xff, R15
- 0000F4 0E4A MOV.W R10, R14
- 0000F6 8E10 SWPB R14
- 0000F8 3EF0FF00 AND.W #0xff, R14
- 0000FC CF4E.... MOV.B R14, aucUartRxBuf(R15)
- 000100 5853 ADD.B #0x1, R8
- 000102 0E3C JMP ??CheckInvalidBlock_8
- 66 }//if
- 67 else
- 68 {
- 69 COLUMN_ADDRESS_LOW=0X00;
- ??CheckInvalidBlock_10:
- 000104 C243.... MOV.B #0x0, &COLUMN_ADDRESS_LOW
- 70 COLUMN_ADDRESS_HIGH=0X00;
- 000108 C243.... MOV.B #0x0, &COLUMN_ADDRESS_HIGH
- 71 ROW_ADDRESS_LOW=ucRxBufFullCnt;
- 00010C C246.... MOV.B R6, &ROW_ADDRESS_LOW
- 72 ROW_ADDRESS_HIGH=0X00;
- 000110 C243.... MOV.B #0x0, &ROW_ADDRESS_HIGH
- 73 PROGRAM_256_BYTE();
- 000114 B012.... CALL #PROGRAM_256_BYTE
- 74 ucRxBufFullCnt++;
- 000118 5653 ADD.B #0x1, R6
- 00011A 023C JMP ??CheckInvalidBlock_8
- 75 }//else
- 76 break;
- 77 }//if unequal
- 78
- 79 }//for next byte
- ??CheckInvalidBlock_9:
- 00011C 1B53 ADD.W #0x1, R11
- 00011E CE3F JMP ??CheckInvalidBlock_1
- 80 if (ucFlashReadData!=ucFlashWriteData){break;}//next block
- ??CheckInvalidBlock_8:
- 000120 4594 CMP.B R4, R5
- 000122 6220 JNE ??CheckInvalidBlock_7
- 81
- 82 ucFlashWriteData=0x00;
- 000124 4443 MOV.B #0x0, R4
- 83 PROGRAM_ONE_PAGE(ucFlashWriteData);
- 000126 4C44 MOV.B R4, R12
- 000128 B012.... CALL #PROGRAM_ONE_PAGE
- 84 //COMMAND
- 85 COMMAND_VAL=0x00; //#0X00
- 00012C C243.... MOV.B #0x0, &COMMAND_VAL
- 86 COMMAND_LATCH_INTO();
- 000130 B012.... CALL #COMMAND_LATCH_INTO
- 87 //ADDRESS
- 88 ADDRESS_VALUE=COLUMN_ADDRESS_LOW; //#0X00
- 000134 D242........ MOV.B &COLUMN_ADDRESS_LOW, &ADDRESS_VALUE
- 89 ADDRESS_LATCH_INTO();
- 00013A B012.... CALL #ADDRESS_LATCH_INTO
- 90
- 91 ADDRESS_VALUE=COLUMN_ADDRESS_HIGH; //#0X00
- 00013E D242........ MOV.B &COLUMN_ADDRESS_HIGH, &ADDRESS_VALUE
- 92 ADDRESS_LATCH_INTO();
- 000144 B012.... CALL #ADDRESS_LATCH_INTO
- 93
- 94 ADDRESS_VALUE=ROW_ADDRESS_LOW; //#0X00
- 000148 D242........ MOV.B &ROW_ADDRESS_LOW, &ADDRESS_VALUE
- 95 ADDRESS_LATCH_INTO();
- 00014E B012.... CALL #ADDRESS_LATCH_INTO
- 96
- 97 ADDRESS_VALUE=ROW_ADDRESS_HIGH; //#0X00
- 000152 D242........ MOV.B &ROW_ADDRESS_HIGH, &ADDRESS_VALUE
- 98 ADDRESS_LATCH_INTO();
- 000158 B012.... CALL #ADDRESS_LATCH_INTO
- 99 FLASH_CON_PORT_OUT &=~ ALE;
- 00015C E2C32900 BIC.B #0x2, &0x29
- 100
- 101 COMMAND_VAL=0X30;
- 000160 F2403000.... MOV.B #0x30, &COMMAND_VAL
- 102 COMMAND_LATCH_INTO();
- 000166 B012.... CALL #COMMAND_LATCH_INTO
- 103 //ATcmdDelay();
- 104 //for(wGeneralCnt=0;wGeneralCnt<0xff;wGeneralCnt++); //delay
- 105 while((FLASH_CON_PORT_IN & RB)==0);
- ??CheckInvalidBlock_2:
- 00016A F2B020002800 BIT.B #0x20, &0x28
- 000170 FC2B JNC ??CheckInvalidBlock_2
- 106 DATA_PORT_IN_INITIAL; //MCU INPUT,MCU READ A DATA
- 000172 C2433200 MOV.B #0x0, &0x32
- 107 for(wByteCnt=0;wByteCnt<2112;wByteCnt++)
- 000176 0B43 MOV.W #0x0, R11
- ??CheckInvalidBlock_3:
- 000178 3B904008 CMP.W #0x840, R11
- 00017C 2F2C JC ??CheckInvalidBlock_11
- 108 {
- 109 FLASH_CON_PORT_OUT &=~ RE; //RE IS LOW,ENABLE READ DATA
- 00017E F2C010002900 BIC.B #0x10, &0x29
- 110 ucFlashReadData=DATA_PORT_IN;
- 000184 55423000 MOV.B &0x30, R5
- 111 FLASH_CON_PORT_OUT |= RE;
- 000188 F2D010002900 BIS.B #0x10, &0x29
- 112
- 113 if (ucFlashReadData!=ucFlashWriteData)
- 00018E 4594 CMP.B R4, R5
- 000190 2324 JEQ ??CheckInvalidBlock_12
- 114 {
- 115 if (ucBadBlockCnt++<128)
- 000192 4E49 MOV.B R9, R14
- 000194 5943 MOV.B #0x1, R9
- 000196 495E ADD.B R14, R9
- 000198 7E908000 CMP.B #0x80, R14
- 00019C 112C JC ??CheckInvalidBlock_13
- 116 {
- 117 aucUartRxBuf[ucRxIndex++]=wBlockAddress & 0xff; //low 8 byte
- 00019E 4E48 MOV.B R8, R14
- 0001A0 3EF0FF00 AND.W #0xff, R14
- 0001A4 CE4A.... MOV.B R10, aucUartRxBuf(R14)
- 0001A8 5853 ADD.B #0x1, R8
- 118 aucUartRxBuf[ucRxIndex++]=(wBlockAddress>>8) & 0xff; //high 8 byte
- 0001AA 4F48 MOV.B R8, R15
- 0001AC 3FF0FF00 AND.W #0xff, R15
- 0001B0 0E4A MOV.W R10, R14
- 0001B2 8E10 SWPB R14
- 0001B4 3EF0FF00 AND.W #0xff, R14
- 0001B8 CF4E.... MOV.B R14, aucUartRxBuf(R15)
- 0001BC 5853 ADD.B #0x1, R8
- 0001BE 0E3C JMP ??CheckInvalidBlock_11
- 119 }//if
- 120 else
- 121 {
- 122 COLUMN_ADDRESS_LOW=0X00;
- ??CheckInvalidBlock_13:
- 0001C0 C243.... MOV.B #0x0, &COLUMN_ADDRESS_LOW
- 123 COLUMN_ADDRESS_HIGH=0X00;
- 0001C4 C243.... MOV.B #0x0, &COLUMN_ADDRESS_HIGH
- 124 ROW_ADDRESS_LOW=ucRxBufFullCnt;
- 0001C8 C246.... MOV.B R6, &ROW_ADDRESS_LOW
- 125 ROW_ADDRESS_HIGH=0X00;
- 0001CC C243.... MOV.B #0x0, &ROW_ADDRESS_HIGH
- 126 PROGRAM_256_BYTE();
- 0001D0 B012.... CALL #PROGRAM_256_BYTE
- 127 ucRxBufFullCnt++;
- 0001D4 5653 ADD.B #0x1, R6
- 0001D6 023C JMP ??CheckInvalidBlock_11
- 128 }//else
- 129 break;
- 130 }//if unequal
- 131
- 132 }//for next byte
- ??CheckInvalidBlock_12:
- 0001D8 1B53 ADD.W #0x1, R11
- 0001DA CE3F JMP ??CheckInvalidBlock_3
- 133 if (ucFlashReadData!=ucFlashWriteData){break;}//next block
- ??CheckInvalidBlock_11:
- 0001DC 4594 CMP.B R4, R5
- 0001DE 0420 JNE ??CheckInvalidBlock_7
- 134 }//for next page
- 0001E0 D1530000 ADD.B #0x1, 0x0(SP)
- 0001E4 1753 ADD.W #0x1, R7
- 0001E6 373F JMP ??CheckInvalidBlock_4
- 135 _NOP();
- ??CheckInvalidBlock_7:
- 0001E8 0343 NOP
- 136 }//for next block
- 0001EA 1A53 ADD.W #0x1, R10
- 0001EC 213F JMP ??CheckInvalidBlock_5
- 137 if (ucBadBlockCnt!=0)
- ??CheckInvalidBlock_6:
- 0001EE 4993 CMP.B #0x0, R9
- 0001F0 0B24 JEQ ??CheckInvalidBlock_14
- 138 {
- 139 COLUMN_ADDRESS_LOW=0X00;
- 0001F2 C243.... MOV.B #0x0, &COLUMN_ADDRESS_LOW
- 140 COLUMN_ADDRESS_HIGH=0X00;
- 0001F6 C243.... MOV.B #0x0, &COLUMN_ADDRESS_HIGH
- 141 ROW_ADDRESS_LOW=ucRxBufFullCnt;//first block
- 0001FA C246.... MOV.B R6, &ROW_ADDRESS_LOW
- 142 ROW_ADDRESS_HIGH=0X00;
- 0001FE C243.... MOV.B #0x0, &ROW_ADDRESS_HIGH
- 143 PROGRAM_256_BYTE();
- 000202 B012.... CALL #PROGRAM_256_BYTE
- 144 ucRxBufFullCnt++;
- 000206 5653 ADD.B #0x1, R6
- 145 }
- 146 }
- ??CheckInvalidBlock_14:
- 000208 2153 ADD.W #0x2, SP
- 00020A 3040.... BR #?Epilogue8
- 147 /*
- 148 void CheckInvalidBlockForNewFlash(void) //64*256Bytes=2^14 bytes
- 149 {
- 150 unsigned int wPageAddress=0, wBlockAddress=0;
- 151 unsigned char ucBadBlockCnt=0,ucRxIndex=0,
- 152 ucRxBufFullCnt=0,ucFlashReadData,
- 153 ucGeneralCnt;
- 154
- 155
- 156 COLUMN_ADDRESS_LOW=0X00; //check "FF" at the column address 2048 of
- 157 COLUMN_ADDRESS_HIGH=0X08; //the 1st and 2nd page in the block
- 158 while (!(wBlockAddress++==1023))
- 159 {
- 160 wPageAddress=wBlockAddress<<6;
- 161 ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- 162 ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- 163 for (ucGeneralCnt=0;ucGeneralCnt<2;ucGeneralCnt++,wPageAddress++)
- 164 {
- 165 //COMMAND
- 166 COMMAND_VAL=0x00; //#0X00 //00H READ1 0-2111BYTE
- 167 COMMAND_LATCH_INTO();
- 168 //ADDRESS
- 169 ADDRESS_VALUE=COLUMN_ADDRESS_LOW;
- 170 ADDRESS_LATCH_INTO();
- 171
- 172 ADDRESS_VALUE=COLUMN_ADDRESS_HIGH;
- 173 ADDRESS_LATCH_INTO();
- 174
- 175 ADDRESS_VALUE=wPageAddress & 0xff; //ROW_ADDRESS_LOW; a bug of Dec. 07,2006
- 176 ADDRESS_LATCH_INTO();
- 177
- 178 ADDRESS_VALUE=(wPageAddress>>8) & 0xff;
- 179 ADDRESS_LATCH_INTO();
- 180 FLASH_CON_PORT_OUT &=~ ALE;
- 181
- 182 COMMAND_VAL=0X30;
- 183 COMMAND_LATCH_INTO();
- 184 //ATcmdDelay();
- 185 while((FLASH_CON_PORT_IN & RB)==0);
- 186 DATA_PORT_IN_INITIAL;
- 187 FLASH_CON_PORT_OUT &=~ RE; //RE IS LOW,ENABLE READ DATA
- 188 ucFlashReadData=DATA_PORT_IN;
- 189 FLASH_CON_PORT_OUT |= RE;
- 190 if (0xff != ucFlashReadData)
- 191 {
- 192 if (ucBadBlockCnt++<128)
- 193 {
- 194 aucUartRxBuf[ucRxIndex++]=wBlockAddress & 0xff; //low 8 byte
- 195 aucUartRxBuf[ucRxIndex++]=(wBlockAddress>>8) & 0xff; //high 8 byte
- 196 }//if
- 197 else
- 198 {
- 199 COLUMN_ADDRESS_LOW=0X00;
- 200 COLUMN_ADDRESS_HIGH=0X00;
- 201 ROW_ADDRESS_LOW=ucRxBufFullCnt;
- 202 ROW_ADDRESS_HIGH=0X00;
- 203 PROGRAM_256_BYTE();
- 204 ucRxBufFullCnt++;
- 205 }//else
- 206 break; //first page or second page
- 207 }//if
- 208 //else
- 209 //ROW_ADDRESS_LOW++; //next page-->2nd page in the block //a bug of Dec. 07,2006
- 210 }//for
- 211 }//while
- 212
- 213 if (ucBadBlockCnt!=0)
- 214 {
- 215 COLUMN_ADDRESS_LOW=0X00;
- 216 COLUMN_ADDRESS_HIGH=0X00;
- 217 ROW_ADDRESS_LOW=ucRxBufFullCnt;//first block
- 218 ROW_ADDRESS_HIGH=0X00;
- 219 PROGRAM_256_BYTE();
- 220
- 221 ucRxBufFullCnt++;
- 222 }
- 223
- 224 FlashFormat();
- 225
- 226 }
- 227 */
- 228
- In segment CODE, align 2, keep-with-next
- 229 unsigned int CalNextPageAddress(unsigned int wCurrentPageAddress)
- CalNextPageAddress:
- 230 {
- 000000 0A12 PUSH.W R10
- 000002 0B12 PUSH.W R11
- 000004 0812 PUSH.W R8
- 000006 0912 PUSH.W R9
- 000008 0612 PUSH.W R6
- 00000A 0712 PUSH.W R7
- 00000C 094C MOV.W R12, R9
- 231 unsigned char ucGeneralCnt=0,ucRxIndex=0,ucBadBlockCnt=0;
- 00000E 4743 MOV.B #0x0, R7
- 000010 4A43 MOV.B #0x0, R10
- 000012 4643 MOV.B #0x0, R6
- 232 unsigned int wBlockAddress=0,wNextPageAddress=0;
- 000014 0B43 MOV.W #0x0, R11
- 000016 0843 MOV.W #0x0, R8
- 233
- 234 wNextPageAddress=wCurrentPageAddress;
- 000018 0849 MOV.W R9, R8
- 235 wBlockAddress=wCurrentPageAddress>>6;
- 00001A 0C49 MOV.W R9, R12
- 00001C B012.... CALL #?ShiftRight16u_6
- 000020 0B4C MOV.W R12, R11
- 236 if (wCurrentPageAddress%64==0)
- 000022 0C49 MOV.W R9, R12
- 000024 3E404000 MOV.W #0x40, R14
- 000028 B012.... CALL #?DivMod16u
- 00002C 0E93 CMP.W #0x0, R14
- 00002E 8820 JNE ??CalNextPageAddress_2
- 237 {
- 238 for (ucGeneralCnt=0;ucGeneralCnt<64;ucGeneralCnt++,ROW_ADDRESS_LOW++)
- 000030 4743 MOV.B #0x0, R7
- ??CalNextPageAddress_1:
- 000032 77904000 CMP.B #0x40, R7
- 000036 842C JC ??CalNextPageAddress_2
- 239 {
- 240 READ_256_BYTE();
- 000038 B012.... CALL #READ_256_BYTE
- 241 for (ucRxIndex=0,ucBadBlockCnt=0;ucBadBlockCnt<128;ucBadBlockCnt++)
- 00003C 4A43 MOV.B #0x0, R10
- 00003E 4643 MOV.B #0x0, R6
- ??CalNextPageAddress_0:
- 000040 76908000 CMP.B #0x80, R6
- 000044 3E2C JC ??CalNextPageAddress_3
- 242 {
- 243 if (aucUartRxBuf[ucRxIndex]==(wBlockAddress & 0xff)
- 244 && aucUartRxBuf[ucRxIndex+1]==((wBlockAddress>>8) & 0xff))
- 000046 4E4A MOV.B R10, R14
- 000048 3EF0FF00 AND.W #0xff, R14
- 00004C 4F4B MOV.B R11, R15
- 00004E 7FF3 AND.B #0xff, R15
- 000050 CE9F.... CMP.B R15, aucUartRxBuf(R14)
- 000054 1220 JNE ??CalNextPageAddress_4
- 000056 3F40.... MOV.W #aucUartRxBuf, R15
- 00005A 4E4A MOV.B R10, R14
- 00005C 3EF0FF00 AND.W #0xff, R14
- 000060 0F5E ADD.W R14, R15
- 000062 0E4B MOV.W R11, R14
- 000064 8E10 SWPB R14
- 000066 3EF0FF00 AND.W #0xff, R14
- 00006A CF9E0100 CMP.B R14, 0x1(R15)
- 00006E 0520 JNE ??CalNextPageAddress_4
- 245 {wNextPageAddress=wCurrentPageAddress+64; break;}
- 000070 3E404000 MOV.W #0x40, R14
- 000074 0E59 ADD.W R9, R14
- 000076 084E MOV.W R14, R8
- 000078 243C JMP ??CalNextPageAddress_3
- 246 if (aucUartRxBuf[ucRxIndex]==0xFF && aucUartRxBuf[ucRxIndex+1]==0xFF &&
- 247 aucUartRxBuf[ucRxIndex+2]==0xFF &&aucUartRxBuf[ucRxIndex+3]==0xFF)
- ??CalNextPageAddress_4:
- 00007A 4E4A MOV.B R10, R14
- 00007C 3EF0FF00 AND.W #0xff, R14
- 000080 FE93.... CMP.B #0xff, aucUartRxBuf(R14)
- 000084 1B20 JNE ??CalNextPageAddress_5
- 000086 3E40.... MOV.W #aucUartRxBuf, R14
- 00008A 4F4A MOV.B R10, R15
- 00008C 3FF0FF00 AND.W #0xff, R15
- 000090 0E5F ADD.W R15, R14
- 000092 FE930100 CMP.B #0xff, 0x1(R14)
- 000096 1220 JNE ??CalNextPageAddress_5
- 000098 3E40.... MOV.W #aucUartRxBuf, R14
- 00009C 4F4A MOV.B R10, R15
- 00009E 3FF0FF00 AND.W #0xff, R15
- 0000A2 0E5F ADD.W R15, R14
- 0000A4 FE930200 CMP.B #0xff, 0x2(R14)
- 0000A8 0920 JNE ??CalNextPageAddress_5
- 0000AA 3E40.... MOV.W #aucUartRxBuf, R14
- 0000AE 4F4A MOV.B R10, R15
- 0000B0 3FF0FF00 AND.W #0xff, R15
- 0000B4 0E5F ADD.W R15, R14
- 0000B6 FE930300 CMP.B #0xff, 0x3(R14)
- 0000BA 0324 JEQ ??CalNextPageAddress_3
- 248 {break;}
- 249 ucRxIndex+=2;
- ??CalNextPageAddress_5:
- 0000BC 6A53 ADD.B #0x2, R10
- 250 }//for
- 0000BE 5653 ADD.B #0x1, R6
- 0000C0 BF3F JMP ??CalNextPageAddress_0
- 251 if (aucUartRxBuf[ucRxIndex++]==(wBlockAddress & 0xff)
- 252 && aucUartRxBuf[ucRxIndex++]==((wBlockAddress>>8) & 0xff))
- ??CalNextPageAddress_3:
- 0000C2 4E4A MOV.B R10, R14
- 0000C4 5A43 MOV.B #0x1, R10
- 0000C6 4A5E ADD.B R14, R10
- 0000C8 3EF0FF00 AND.W #0xff, R14
- 0000CC 4F4B MOV.B R11, R15
- 0000CE 7FF3 AND.B #0xff, R15
- 0000D0 CE9F.... CMP.B R15, aucUartRxBuf(R14)
- 0000D4 1120 JNE ??CalNextPageAddress_6
- 0000D6 4F4A MOV.B R10, R15
- 0000D8 5A43 MOV.B #0x1, R10
- 0000DA 4A5F ADD.B R15, R10
- 0000DC 3FF0FF00 AND.W #0xff, R15
- 0000E0 0E4B MOV.W R11, R14
- 0000E2 8E10 SWPB R14
- 0000E4 3EF0FF00 AND.W #0xff, R14
- 0000E8 CF9E.... CMP.B R14, aucUartRxBuf(R15)
- 0000EC 0520 JNE ??CalNextPageAddress_6
- 253 {wNextPageAddress=wCurrentPageAddress+64; break;}
- 0000EE 3E404000 MOV.W #0x40, R14
- 0000F2 0E59 ADD.W R9, R14
- 0000F4 084E MOV.W R14, R8
- 0000F6 243C JMP ??CalNextPageAddress_2
- 254 if (aucUartRxBuf[ucRxIndex]==0xFF && aucUartRxBuf[ucRxIndex+1]==0xFF &&
- 255 aucUartRxBuf[ucRxIndex+2]==0xFF &&aucUartRxBuf[ucRxIndex+3]==0xFF)
- ??CalNextPageAddress_6:
- 0000F8 4E4A MOV.B R10, R14
- 0000FA 3EF0FF00 AND.W #0xff, R14
- 0000FE FE93.... CMP.B #0xff, aucUartRxBuf(R14)
- 000102 1A20 JNE ??CalNextPageAddress_7
- 000104 3E40.... MOV.W #aucUartRxBuf, R14
- 000108 4F4A MOV.B R10, R15
- 00010A 3FF0FF00 AND.W #0xff, R15
- 00010E 0E5F ADD.W R15, R14
- 000110 FE930100 CMP.B #0xff, 0x1(R14)
- 000114 1120 JNE ??CalNextPageAddress_7
- 000116 3E40.... MOV.W #aucUartRxBuf, R14
- 00011A 4F4A MOV.B R10, R15
- 00011C 3FF0FF00 AND.W #0xff, R15
- 000120 0E5F ADD.W R15, R14
- 000122 FE930200 CMP.B #0xff, 0x2(R14)
- 000126 0820 JNE ??CalNextPageAddress_7
- 000128 3E40.... MOV.W #aucUartRxBuf, R14
- 00012C 3AF0FF00 AND.W #0xff, R10
- 000130 0E5A ADD.W R10, R14
- 000132 FE930300 CMP.B #0xff, 0x3(R14)
- 000136 0424 JEQ ??CalNextPageAddress_2
- 256 {break;}
- 257 }//for
- ??CalNextPageAddress_7:
- 000138 5753 ADD.B #0x1, R7
- 00013A D253.... ADD.B #0x1, &ROW_ADDRESS_LOW
- 00013E 793F JMP ??CalNextPageAddress_1
- 258 }//if
- 259 return wNextPageAddress;
- ??CalNextPageAddress_2:
- 000140 0C48 MOV.W R8, R12
- 000142 3040.... BR #?Epilogue6
- 260 }
- 261 /*******************
- 262 unsigned int CalNextBlockAddress(unsigned int wCurrentBlockAddress)
- 263 {
- 264 unsigned char ucGeneralCnt=0,ucRxIndex=0,ucBadBlockCnt=0;
- 265 unsigned int wBlockAddress=0,wNextBlockAddress=0;
- 266
- 267 wNextBlockAddress=wCurrentBlockAddress;
- 268 for (ucGeneralCnt=0;ucGeneralCnt<64;ucGeneralCnt++,ROW_ADDRESS_LOW++)
- 269 {
- 270
- 271 READ_256_BYTE();
- 272 for (ucRxIndex=0,ucBadBlockCnt=0;ucBadBlockCnt<128;ucBadBlockCnt++)
- 273 {
- 274 if (aucUartRxBuf[ucRxIndex++]==(wBlockAddress & 0xff)
- 275 && aucUartRxBuf[ucRxIndex++]==((wBlockAddress>>8) & 0xff))
- 276 {wNextBlockAddress=wCurrentBlockAddress+1; break;}
- 277 if (aucUartRxBuf[ucRxIndex]==0xFF && aucUartRxBuf[ucRxIndex+1]==0xFF &&
- 278 aucUartRxBuf[ucRxIndex+2]==0xFF &&aucUartRxBuf[ucRxIndex+3]==0xFF)
- 279 {break;}
- 280 }//for
- 281 if (aucUartRxBuf[ucRxIndex]==0xFF && aucUartRxBuf[ucRxIndex+1]==0xFF &&
- 282 aucUartRxBuf[ucRxIndex+2]==0xFF &&aucUartRxBuf[ucRxIndex+3]==0xFF)
- 283 {break;}
- 284 }//for
- 285 return wNextBlockAddress;
- 286 }
- 287 *******************************/
- In segment CODE, align 2, keep-with-next
- 288 void FlashFormat(void)
- FlashFormat:
- 289 {
- 000000 0A12 PUSH.W R10
- 000002 0B12 PUSH.W R11
- 290 unsigned int wBlockAddress=0,wPageAddress=0;
- 000004 0A43 MOV.W #0x0, R10
- 000006 0B43 MOV.W #0x0, R11
- 291 for (wBlockAddress=1;wBlockAddress<1024;wBlockAddress++)
- 000008 1A43 MOV.W #0x1, R10
- ??FlashFormat_0:
- 00000A 3A900004 CMP.W #0x400, R10
- 00000E 102C JC ??FlashFormat_1
- 292 {
- 293 wPageAddress=wBlockAddress<<6;
- 000010 0C4A MOV.W R10, R12
- 000012 B012.... CALL #?ShiftLeft16_6
- 000016 0B4C MOV.W R12, R11
- 294 ROW_ADDRESS_LOW=wPageAddress & 0XFF;
- 000018 C24B.... MOV.B R11, &ROW_ADDRESS_LOW
- 295 ROW_ADDRESS_HIGH=(wPageAddress>>8) & 0XFF;
- 00001C 0E4B MOV.W R11, R14
- 00001E 8E10 SWPB R14
- 000020 3EF0FF00 AND.W #0xff, R14
- 000024 C24E.... MOV.B R14, &ROW_ADDRESS_HIGH
- 296 ERASE_ONE_BLOCK();
- 000028 B012.... CALL #ERASE_ONE_BLOCK
- 297 }
- 00002C 1A53 ADD.W #0x1, R10
- 00002E ED3F JMP ??FlashFormat_0
- 298 }
- ??FlashFormat_1:
- 000030 3B41 POP.W R11
- 000032 3A41 POP.W R10
- 000034 3041 RET
- Maximum stack usage in bytes:
- Function CSTACK
- -------- ------
- CalNextPageAddress 14
- -> READ_256_BYTE 14
- CheckInvalidBlock 20
- -> ZERO_ADDRESS 20
- -> ERASE_ONE_BLOCK 20
- -> ERASE_ONE_BLOCK 20
- -> COMMAND_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> COMMAND_LATCH_INTO 20
- -> PROGRAM_256_BYTE 20
- -> PROGRAM_ONE_PAGE 20
- -> COMMAND_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> ADDRESS_LATCH_INTO 20
- -> COMMAND_LATCH_INTO 20
- -> PROGRAM_256_BYTE 20
- -> PROGRAM_256_BYTE 20
- FlashFormat 6
- -> ERASE_ONE_BLOCK 6
- Segment part sizes:
- Function/Label Bytes
- -------------- -----
- P2IN 1
- P2OUT 1
- P5IN 1
- P5DIR 1
- CheckInvalidBlock 526
- CalNextPageAddress 326
- FlashFormat 54
-
- 906 bytes in segment CODE
- 4 bytes in segment DATA16_AN
-
- 906 bytes of CODE memory
- 0 bytes of DATA memory (+ 4 bytes shared)
- Errors: none
- Warnings: none