progctrl.rmh

来自「和picoblaze完全兼容的mcu ip core」· RMH 代码 · 共 1,519 行 · 第 1/5 页

RMH
1,519
字号
// #91: CONSTANT(character_o,111)// #92: CONSTANT(character_p,112)// #93: CONSTANT(character_q,113)// #94: CONSTANT(character_r,114)// #95: CONSTANT(character_s,115)// #96: CONSTANT(character_t,116)// #97: CONSTANT(character_u,117)// #98: CONSTANT(character_v,118)// #99: CONSTANT(character_w,119)// #100: CONSTANT(character_x,120)// #101: CONSTANT(character_y,121)// #102: CONSTANT(character_z,122)// #103: CONSTANT(character_A,65)// #104: CONSTANT(character_B,66)// #105: CONSTANT(character_C,67)// #106: CONSTANT(character_D,68)// #107: CONSTANT(character_E,69)// #108: CONSTANT(character_F,70)// #109: CONSTANT(character_G,71)// #110: CONSTANT(character_H,72)// #111: CONSTANT(character_I,73)// #112: CONSTANT(character_J,74)// #113: CONSTANT(character_K,75)// #114: CONSTANT(character_L,76)// #115: CONSTANT(character_M,77)// #116: CONSTANT(character_N,78)// #117: CONSTANT(character_O,79)// #118: CONSTANT(character_P,80)// #119: CONSTANT(character_Q,81)// #120: CONSTANT(character_R,82)// #121: CONSTANT(character_S,83)// #122: CONSTANT(character_T,84)// #123: CONSTANT(character_U,85)// #124: CONSTANT(character_V,86)// #125: CONSTANT(character_W,87)// #126: CONSTANT(character_X,88)// #127: CONSTANT(character_Y,89)// #128: CONSTANT(character_Z,90)// #129: CONSTANT(character_0,48)// #130: CONSTANT(character_1,49)// #131: CONSTANT(character_2,50)// #132: CONSTANT(character_3,51)// #133: CONSTANT(character_4,52)// #134: CONSTANT(character_5,53)// #135: CONSTANT(character_6,54)// #136: CONSTANT(character_7,55)// #137: CONSTANT(character_8,56)// #138: CONSTANT(character_9,57)// #139: CONSTANT(character_colon,58)// #140: CONSTANT(character_fullstop,46)// #141: CONSTANT(character_semi_colon,59)// #142: CONSTANT(character_minus,45)// #143: CONSTANT(character_plus,43)// #144: CONSTANT(character_comma,44)// #145: CONSTANT(character_less_than,60) ;'<'// #146: CONSTANT(character_greater_than,62) ;'>'// #147: CONSTANT(character_open,40) ;'('// #148: CONSTANT(character_close,41) ;')'// #149: CONSTANT(character_divide,47) ;'/'// #150: CONSTANT(character_equals,61)// #151: CONSTANT(character_space,32)// #152: CONSTANT(character_CR,13) ;carriage return// #153: CONSTANT(character_LF,10) ;line feed// #154: CONSTANT(character_question,63) ;'?'// #155: CONSTANT(character_dollar,36)// #156: CONSTANT(character_exclaim,33) ;'!'// #157: CONSTANT(character_BS,8) ;Back Space command character// #158: CONSTANT(character_XON,17) ;Flow control ON// #159: CONSTANT(character_XOFF,19) ;Flow control OFF// #160: ;// #161: ;// #162: ;**************************************************************************************// #163: ; Scratch Pad Memory Locations// #164: ;**************************************************************************************// #165: ;// #166: CONSTANT(ISR_preserve_s0,0) ;preserve register during ISR// #167: ;// #168: ;// #169: ;// #170: ;Store up to one line of an MCS file as bytes// #171: ;A typical data line consists of:-// #172: ;:     Start character which is not stored// #173: ;10    Number of data bytes included (16 in this case)// #174: ;aaaa  Lower 16-bits of the storage address// #175: ;00    Record type (data in this case)// #176: ;dddd...   Data bytes (typically 16 which is the maximum)// #177: ;cc    Checksum// #178: ;CR/LF Line will end in carriage return and/or line feed which is not stored.// #179: ;// #180: ;So a total of 21 bytes could be stored before processing.// #181: ;This is located at the end of scratch pad memory.// #182: ;// #183: CONSTANT(line_start,43) ;21 bytes until end of memory// #184: CONSTANT(data_start,47) ;Start of data field if present// #185: ;// #186: ;// #187: ;**************************************************************************************// #188: ; Initialise the system and welcome message// #189: ;**************************************************************************************// #190: ;// @000 #191: [cold_start]30027 // @000 #191: CALL(SF_init) ;initialise StrataFLASH controls3011a // @001 #192: CALL(delay_1s) ;delay because UART is fast and JTAG startup sequence can be slow3c001 // @002 #193: ENABLE(INTERRUPT) ;Interrupt is used for XON/XOFF flow control// @003 #194: [welcome_start]30193 // @003 #194: CALL(send_CR)30199 // @004 #195: CALL(send_welcome) ;start up message and version number// #196: ;// #197: ;// #198: ;**************************************************************************************// #199: ; Main menu and command selection// #200: ;**************************************************************************************// #201: ;// #202: ;// @005 #203: [warm_start]30233 // @005 #203: CALL(send_Menu) ;Menu and command selection30193 // @006 #204: CALL(send_CR)// #205: ;// @007 #206: [prompt]30193 // @007 #206: CALL(send_CR)30193 // @008 #207: CALL(send_CR)00f3e // @009 #208: LOAD(UART_data,character_greater_than) ;prompt for input30131 // @00a #209: CALL(send_to_UART)30022 // @00b #210: CALL(read_upper_case)14045 // @00c #211: COMPARE(s0,character_E) ;test for commands and execute as required3502a // @00d #212: JUMP(Z,erase_command)14042 // @00e #213: COMPARE(s0,character_B)3502c // @00f #214: JUMP(Z,block_erase_command)14050 // @010 #215: COMPARE(s0,character_P)35047 // @011 #216: JUMP(Z,program_command)14057 // @012 #217: COMPARE(s0,character_W)3508c // @013 #218: JUMP(Z,write_command)14052 // @014 #219: COMPARE(s0,character_R)350a3 // @015 #220: JUMP(Z,read_command)14049 // @016 #221: COMPARE(s0,character_I)350c2 // @017 #222: JUMP(Z,SF_information)14048 // @018 #223: COMPARE(s0,character_H)35003 // @019 #224: JUMP(Z,welcome_start)14053 // @01a #225: COMPARE(s0,character_S)350d5 // @01b #226: JUMP(Z,SF_status)30193 // @01c #227: CALL(send_CR) ;no valid command input00f3f // @01d #228: LOAD(UART_data,character_question) ;display ???30131 // @01e #229: CALL(send_to_UART)30131 // @01f #230: CALL(send_to_UART)30131 // @020 #231: CALL(send_to_UART)34007 // @021 #232: JUMP(prompt) ;Try again!// #233: ;// #234: ;// @022 #235: [read_upper_case]3011f // @022 #235: CALL(read_from_UART) ;read command character from UART30131 // @023 #236: CALL(send_to_UART) ;echo character010f0 // @024 #237: LOAD(s0,UART_data) ;convert to upper case3013e // @025 #238: CALL(upper_case)2a000 // @026 #239: RETURN// #240: ;// #241: ;// #242: ;**************************************************************************************// #243: ; Initialise the StrataFlash Memory control signals.// #244: ;**************************************************************************************// #245: ;// #246: ; SF_read = 0   - Output enable off// #247: ; SF_ce = 1     - Deselect StrataFLASH memory// #248: ; SF_we = 1     - Write enable off// #249: ;// #250: ; Register used s0// #251: ;// @027 #252: [SF_init]00006 // @027 #252: LOAD(s0,6)2c008 // @028 #253: OUTPUT(s0,SF_control_port)2a000 // @029 #254: RETURN// #255: ;// #256: ;// #257: ;**************************************************************************************// #258: ; Erase Command - Perform bulk erase of the StrataFLASH memory// #259: ;**************************************************************************************// #260: ;// #261: ; This routine executes the block erase command 128 times with a different base// #262: ; address in each case.// #263: ;// #264: ; Note that this could take as long as 8 minutes 30 seconds// #265: ; and even typical times will be approximately 2 minutes.// #266: ;// #267: ; Registers used s1,s7,s8,s9// #268: ;// @02a #269: [erase_command]009fe // @02a #269: LOAD(s9,FE) ;define base address of block 127 = FE00003402d // @02b #270: JUMP(blocks_erase)// #271: ;// #272: ;// #273: ;**************************************************************************************// #274: ; Block Erase Command - Performs erase of lowest 3 blocks of StrataFLASH memory which// #275: ; covers the address range 000000 to 05FFFF in which the configuration for an XC3S500E// #276: ; would be able to fit (000000 to 045470).// #277: ;**************************************************************************************// #278: ;// #279: ; This routine executes the block erase command 3 times with a different base// #280: ; address in each case.// #281: ;// #282: ; Each block is 128K bytes and therefore has an address range of 000000 to 01FFFF.// #283: ; So each block is separated by 020000 hex.// #284: ;// #285: ; Registers used s0,s1,s7,s8,s9// #286: ;// @02c #287: [block_erase_command]00904 // @02c #287: LOAD(s9,4) ;define base address of block 3 = 040000// @02d #288: [blocks_erase]30193 // @02d #288: CALL(send_CR)302d4 // @02e #289: CALL(send_Confirm) ;confirm command with a 'Y' which must be upper case3011f // @02f #290: CALL(read_from_UART) ;read command character from UART30131 // @030 #291: CALL(send_to_UART) ;echo input14f59 // @031 #292: COMPARE(UART_data,character_Y)3543f // @032 #293: JUMP(NZ,abort_erase)30193 // @033 #294: CALL(send_CR)30209 // @034 #295: CALL(send_Erase_in_progress)30193 // @035 #296: CALL(send_CR)00800 // @036 #297: LOAD(s8,0) ;define lower address of each block = xx000000700 // @037 #298: LOAD(s7,0)// @038 #299: [blocks_erase_loop]00f2e // @038 #299: LOAD(UART_data,character_fullstop) ;progress dots30131 // @039 #300: CALL(send_to_UART)30041 // @03a #301: CALL(SF_erase_block) ;erase block1c902 // @03b #302: SUB(s9,2) ;decrement base address by 1 block35c38 // @03c #303: JUMP(NC,blocks_erase_loop) ;repeat until block 0 is erased3022c // @03d #304: CALL(send_OK)34007 // @03e #305: JUMP(prompt)// #306: ;// @03f #307: [abort_erase]302f1 // @03f #307: CALL(send_Abort)34007 // @040 #308: JUMP(prompt)// #309: ;// #310: ;// #311: ;**************************************************************************************// #312: ; Erase a single 128K Byte block of the StrataFlash Memory// #313: ;**************************************************************************************// #314: ;// #315: ; The 24-bit address of the block should be supplied in register set [s9,s8,s7].// #316: ;// #317: ; To erase a block the address must be set and then the block erase command (20 hex)// #318: ; written to the memory followed by the write confirm command (D0 hex).// #319: ;// #320: ; The act of erasing a block may take up to 1 second to complete. This routine// #321: ; waits for the memory to be ready before restoring the normal read array mode and// #322: ; returning.// #323: ;// #324: ; Registers used s1,s7,s8,s9// #325: ;// @041 #326: [SF_erase_block]00120 // @041 #326: LOAD(s1,32) ;block erase command300ea // @042 #327: CALL(SF_byte_write)001d0 // @043 #328: LOAD(s1,D0) ;write confirm command300ea // @044 #329: CALL(SF_byte_write)300f7 // @045 #330: CALL(wait_SF_ready) ;wait for erase to complete2a000 // @046 #331: RETURN// #332: ;// #333: ;// #334: ;**************************************************************************************// #335: ; Program Command - Program StrataFLASH memory with data defined in an MCS file// #336: ;**************************************************************************************// #337: ;// @047 #338: [program_command]30193 // @047 #338: CALL(send_CR)301e2 // @048 #339: CALL(send_Waiting_MCS_file)3004c // @049 #340: CALL(program_MCS)3022c // @04a #341: CALL(send_OK)34007 // @04b #342: JUMP(prompt)// #343: ;// #344: ;**************************************************************************************// #345: ; Program StrataFLASH memory with data defined in an MCS file// #346: ;**************************************************************************************// #347: ;// #348: ;Reads the MCS file from the UART and programs the Strata FLASH device at the locations.// #349: ;specified by the file contents.// #350: ;// #351: ;This routine will continue until an end of file record is detected.// #352: ;For each line of MCS received, the current address will be output so that// #353: ;progress can be monitored.// #354: ;// #355: ;// @04c #356: [program_MCS]30057 // @04c #356: CALL(read_MCS_line) ;read line from UART30067 // @04d #357: CALL(MCS_address) ;find start address and record type14b01 // @04e #358: COMPARE(sB,1) ;test for end record2b000 // @04f #359: RETURN(Z) ;end of programming14b04 // @050 #360: COMPARE(sB,4) ;test for extended address record3504c // @051 #361: JUMP(Z,program_MCS) ;no data with this record and upper address now correct// #362: ;// #363: ;Assume data record type 00 which is data so need to program specified number// #364: ;of bytes into memory at correct address.// #365: ;// @052 #366: [write_spm_data]3016d // @052 #366: CALL(send_hex_3bytes) ;send address to indicate progress30193 // @053 #367: CALL(send_CR)06a2b // @054 #368: FETCH(sA,line_start) ;read number of data bytes to program30077 // @055 #369: CALL(SF_buffer_write) ;write bytes to memory3404c // @056 #370: JUMP(program_MCS)// #371: ;// #372: ;// #373: ;**************************************************************************************// #374: ;Read one line of an MCS file into scratch pad memory// #375: ;**************************************************************************************// #376: ;// #377: ;Reads one line of MCS file format into scratch pad memory starting at location 'line_start'.// #378: ;// #379: ;The routine detects the line start character ':' ignoring any preceding characters. This

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?