progctrl.rmh
来自「和picoblaze完全兼容的mcu ip core」· RMH 代码 · 共 1,519 行 · 第 1/5 页
RMH
1,519 行
// #380: ;will remove any additional CR or LF characters.// #381: ;// #382: ;It then reads each subsequent pair of ASCII characters, converts them to true hex in the// #383: ;range 00 to FF and stores them in scratch pad memory.// #384: ;// #385: ;The end of the line is determined by either a CR or LF character.// #386: ;// #387: ;The value last returned in register 'sE' will be the pointer to the location in// #388: ;scratch pad memory following the last byte for the line read.// #389: ;// @057 #390: [read_MCS_line]00e2b // @057 #390: LOAD(sE,line_start) ;initialise SPM memory pointer// @058 #391: [wait_MCS_line_Start]3011f // @058 #391: CALL(read_from_UART) ;read character14f3a // @059 #392: COMPARE(UART_data,character_colon) ;test for start character35458 // @05a #393: JUMP(NZ,wait_MCS_line_Start)// @05b #394: [read_MCS_byte]3011f // @05b #394: CALL(read_from_UART) ;read character14f0d // @05c #395: COMPARE(UART_data,character_CR) ;test for end of line2b000 // @05d #396: RETURN(Z)14f0a // @05e #397: COMPARE(UART_data,character_LF) ;test for end of line2b000 // @05f #398: RETURN(Z)013f0 // @060 #399: LOAD(s3,UART_data) ;upper nibble character3011f // @061 #400: CALL(read_from_UART) ;read character012f0 // @062 #401: LOAD(s2,UART_data) ;lower nibble character30174 // @063 #402: CALL(ASCII_byte_to_hex) ;convert to true hex value2f0e0 // @064 #403: STORE(s0,sE) ;write to SPM18e01 // @065 #404: ADD(sE,1) ;increment pointer3405b // @066 #405: JUMP(read_MCS_byte)// #406: ;// #407: ;// #408: ;**************************************************************************************// #409: ;Determine the current address for the line of an MCS file in scratch pad memory// #410: ;**************************************************************************************// #411: ;// #412: ;Checks the existing line data stored in scratch pad memory starting at location// #413: ;'line_start' and determines the current address.// #414: ;// #415: ;The address is in the register set [s9,s8,s7] before and after this routine is// #416: ;executed because not all address bits are defined by a given line of MCS and// #417: ;the undefined bits remain constant.// #418: ;// #419: ;A record type of 04 will update [s9].// #420: ;A record type of 00 will update [s8,s7].// #421: ;// #422: ;On return, the register sB will contain the record type and// #423: ;register sC will indicate the number of data bytes stored.// #424: ;// @067 #425: [MCS_address]00d2b // @067 #425: LOAD(sD,line_start) ;initialise SPM memory pointer07cd0 // @068 #426: FETCH(sC,sD) ;read number of bytes on line18d03 // @069 #427: ADD(sD,3) ;move to record type07bd0 // @06a #428: FETCH(sB,sD) ;read record type14b00 // @06b #429: COMPARE(sB,0) ;test for data record35072 // @06c #430: JUMP(Z,new_low_address)14b04 // @06d #431: COMPARE(sB,4) ;test for data record2b400 // @06e #432: RETURN(NZ)18d02 // @06f #433: ADD(sD,2) ;read upper 8-bits079d0 // @070 #434: FETCH(s9,sD)2a000 // @071 #435: RETURN// @072 #436: [new_low_address]1cd01 // @072 #436: SUB(sD,1) ;read lower 8-bits077d0 // @073 #437: FETCH(s7,sD)1cd01 // @074 #438: SUB(sD,1) ;read middle 8-bits078d0 // @075 #439: FETCH(s8,sD)2a000 // @076 #440: RETURN// #441: ;// #442: ;// #443: ;**************************************************************************************// #444: ; Write to Buffer of StrataFlash Memory and program// #445: ;**************************************************************************************// #446: ;// #447: ; Writing to the buffer allows faster operation than writing individual bytes.// #448: ; The buffer size is limited to 32 locations. To perform a buffer write the process// #449: ; is as follows:-// #450: ; Write command for buffer write to StrataFLASH memory (E8 hex).// #451: ; Base address for writing should also be set.// #452: ; Read Status register and if not ready repeat command until it is.// #453: ; Write a value specifying the number of bytes to be written LESS ONE.// #454: ; In this program the number of bytes will be specified in register sA// #455: ; and this value needs to be decremented before writing to the memory.// #456: ; Write the correct number of actual data bytes with appropriate addresses.// #457: ; Ideally the addresses do not cross the boundary of 32 locations// #458: ; such that LSBs are always in the range 00000 to 11111 binary.// #459: ; Crossing the boundary is OK but will take longer to program.// #460: ; Write command to confirm operation (D0 hex).// #461: ; Read Status register and wait for ready.// #462: ;// #463: ; This routine additionally restores the normal read array mode before returning.// #464: ;// #465: ; The number of bytes to be written should be supplied in register sA and must be// #466: ; a value between 1 and 32 (01 and 20 hex).// #467: ;// #468: ; The 24-bit base address should be supplied in register set [s9,s8,s7].// #469: ; On return, this will be increased by the number of locations written.// #470: ;// #471: ; Scratch pad memory locations starting at location defined by constant// #472: ; 'data_start' should contain the data bytes to be written.// #473: ;// #474: ; The act of writing the buffer to the memory array may take up to 654us to complete.// #475: ; The time taken to program is recorded by register pair [sE,sD]. Each count// #476: ; equates to 15 instructions which is equivalent to 30 clock cycles (600ns at 50MHz).// #477: ;// #478: ; Registers used s0,s1,s7,s8,s9,sA,sD,sE// #479: ;// #480: ;// @077 #481: [SF_buffer_write]001e8 // @077 #481: LOAD(s1,E8) ;command for buffer write300ea // @078 #482: CALL(SF_byte_write)300e0 // @079 #483: CALL(SF_byte_read) ;read status register into s012080 // @07a #484: TEST(s0,128) ;test ready/busy flag35077 // @07b #485: JUMP(Z,SF_buffer_write) ;repeat command until ready011a0 // @07c #486: LOAD(s1,sA) ;Specify number of bytes to write1c101 // @07d #487: SUB(s1,1) ;one less than actual number!300ea // @07e #488: CALL(SF_byte_write)0032f // @07f #489: LOAD(s3,data_start) ;point to data in scratch pad memory// @080 #490: [write_buffer_loop]07130 // @080 #490: FETCH(s1,s3) ;fetch data300ea // @081 #491: CALL(SF_byte_write) ;write to buffer18701 // @082 #492: ADD(s7,1) ;increment address1a800 // @083 #493: ADDCY(s8,0)1a900 // @084 #494: ADDCY(s9,0)18301 // @085 #495: ADD(s3,1) ;increment SPM pointer1ca01 // @086 #496: SUB(sA,1) ;count bytes remaining35480 // @087 #497: JUMP(NZ,write_buffer_loop)001d0 // @088 #498: LOAD(s1,D0) ;command to confirm write300ea // @089 #499: CALL(SF_byte_write)300f7 // @08a #500: CALL(wait_SF_ready) ;wait for program to complete and set read array mode2a000 // @08b #501: RETURN// #502: ;// #503: ;// #504: ;**************************************************************************************// #505: ; Write Command - Write one byte to specified address// #506: ;**************************************************************************************// #507: ;// @08c #508: [write_command]302fe // @08c #508: CALL(send_address) ;obtain 24-bit address 000000 to FFFFFF3018d // @08d #509: CALL(obtain_8bits)3588c // @08e #510: JUMP(C,write_command) ;bad input address01900 // @08f #511: LOAD(s9,s0)3018d // @090 #512: CALL(obtain_8bits)3588c // @091 #513: JUMP(C,write_command) ;bad input address01800 // @092 #514: LOAD(s8,s0)3018d // @093 #515: CALL(obtain_8bits)3588c // @094 #516: JUMP(C,write_command) ;bad input address01700 // @095 #517: LOAD(s7,s0)// @096 #518: [get_data]3030e // @096 #518: CALL(send_data) ;obtain 8-bit data 00 to FF into s03018d // @097 #519: CALL(obtain_8bits)35896 // @098 #520: JUMP(C,get_data) ;bad input data3009d // @099 #521: CALL(SF_single_byte_write)30193 // @09a #522: CALL(send_CR)3022c // @09b #523: CALL(send_OK)34007 // @09c #524: JUMP(prompt)// #525: ;// #526: ;// #527: ;**************************************************************************************// #528: ; Write a single byte to StrataFlash Memory// #529: ;**************************************************************************************// #530: ;// #531: ; To write a single byte to StrataFLASH memory the address must be set and the// #532: ; single-word/byte program command (40 hex) sent to the memory. Then the data byte can// #533: ; be written to the memory using the same address.// #534: ;// #535: ; The 24-bit address should be supplied in register set [s9,s8,s7].// #536: ; Register s0 should contain the byte data to be written to the memory.// #537: ;// #538: ; The act of writing the memory array may take up to 175us to complete. This routine// #539: ; waits for the memory to be ready before restoring the normal read array mode and// #540: ; returning. The time taken to program is recorded by register pair [sE,sD]. Each count// #541: ; equates to 15 instructions which is equivalent to 30 clock cycles (600ns at 50MHz).// #542: ;// #543: ; Registers used s0,s1,s7,s8,s9,sD,sE (s7,s8,s9 not changed)// #544: ;// #545: ; Registers used s0,s1,s7,s8,s9// #546: ;// @09d #547: [SF_single_byte_write]00140 // @09d #547: LOAD(s1,64) ;command for single byte program300ea // @09e #548: CALL(SF_byte_write)01100 // @09f #549: LOAD(s1,s0) ;write data to be programmed300ea // @0a0 #550: CALL(SF_byte_write)300f7 // @0a1 #551: CALL(wait_SF_ready) ;wait for program to complete2a000 // @0a2 #552: RETURN// #553: ;// #554: ;// #555: ;**************************************************************************************// #556: ;Read Command - Read one page of memory at specified address// #557: ;**************************************************************************************// #558: ;// @0a3 #559: [read_command]302fe // @0a3 #559: CALL(send_address) ;obtain 24-bit address 000000 to FFFFFF3018d // @0a4 #560: CALL(obtain_8bits) ;read value from UART358a3 // @0a5 #561: JUMP(C,read_command) ;bad input address01900 // @0a6 #562: LOAD(s9,s0)3018d // @0a7 #563: CALL(obtain_8bits)358a3 // @0a8 #564: JUMP(C,read_command) ;bad input address01800 // @0a9 #565: LOAD(s8,s0)3018d // @0aa #566: CALL(obtain_8bits)358a3 // @0ab #567: JUMP(C,read_command) ;bad input address01700 // @0ac #568: LOAD(s7,s0)30193 // @0ad #569: CALL(send_CR)300b1 // @0ae #570: CALL(send_SF_page)3022c // @0af #571: CALL(send_OK)34007 // @0b0 #572: JUMP(prompt)// #573: ;// #574: ;The start address should be provided in register set [s9,s8,s7].// #575: ;The display will be next 256 bytes displayed as 16 lines of 16 bytes// #576: ;with each line commencing with the address of the first byte.// #577: ;// @0b1 #578: [send_SF_page]00610 // @0b1 #578: LOAD(s6,16) ;16 lines to display// @0b2 #579: [send_SF_line]30193 // @0b2 #579: CALL(send_CR)3016d // @0b3 #580: CALL(send_hex_3bytes) ;display address30196 // @0b4 #581: CALL(send_space)00510 // @0b5 #582: LOAD(s5,16) ;16 bytes to display on a line// @0b6 #583: [send_SF_byte]30196 // @0b6 #583: CALL(send_space)300e0 // @0b7 #584: CALL(SF_byte_read) ;read byte into s018701 // @0b8 #585: ADD(s7,1) ;increment StrataFLASH address1a800 // @0b9 #586: ADDCY(s8,0)1a900 // @0ba #587: ADDCY(s9,0)30167 // @0bb #588: CALL(send_hex_byte) ;display byte1c501 // @0bc #589: SUB(s5,1) ;count bytes per line354b6 // @0bd #590: JUMP(NZ,send_SF_byte)1c601 // @0be #591: SUB(s6,1) ;count lines354b2 // @0bf #592: JUMP(NZ,send_SF_line)30193 // @0c0 #593: CALL(send_CR)2a000 // @0c1 #594: RETURN// #595: ;// #596: ;// #597: ;**************************************************************************************// #598: ; ID Command - Read and display the device information for the StrataFLASH FLASH memory// #599: ;**************************************************************************************// #600: ;// #601: ; Normal response should be// #602: ; Device Manufacturer Code (Intel) = 89 hex// #603: ; Memory ID code for 128Mbit = 18 hex// #604: ;// #605: ; To read the device information the Read device information command (90)// #606: ; must be written to the memory. The information is read back but assumes// #607: ; that 16-bit words are being used and hence address bit0 is not really used.// #608: ; hence addresses 000000 and 0000001 both return the Device Manufacturer Code and// #609: ; addresses 000002 and 0000003 both return the Memory ID code.// #610: ;// #611: ; After reading the device information the read array command is written to the// #612: ; device to put it back to normal read mode.// #613: ;// #614: ; Registers used s0,s7,s8,s9// #615: ;// @0c2 #616: [SF_information]30193 // @0c2 #616: CALL(send_CR) ;send 'ID=' to terminal302c6 // @0c3 #617: CALL(send_ID)00f3d // @0c4 #618: LOAD(UART_data,character_equals)30131 // @0c5 #619: CALL(send_to_UART)30196 // @0c6 #620: CALL(send_space)00900 // @0c7 #621: LOAD(s9,0) ;define base address 00000000800 // @0c8 #622: LOAD(s8,0)00700 // @0c9 #623: LOAD(s7,0)00190 // @0ca #624: LOAD(s1,144) ;command to read device information300ea // @0cb #625: CALL(SF_byte_write)300e0 // @0cc #626: CALL(SF_byte_read) ;read Device Manufacturer Code into s030167 // @0cd #627: CALL(send_hex_byte) ;display byte30196 // @0ce #628: CALL(send_space)00702 // @0cf #629: LOAD(s7,2) ;change address300e0 // @0d0 #630: CALL(SF_byte_read) ;read Memory ID code into s030167 // @0d1 #631: CALL(send_hex_byte) ;display byte30193 // @0d2 #632: CALL(send_CR)300f4 // @0d3 #633: CALL(set_SF_read_array_mode) ;restore normal read array mode34007 // @0d4 #634: JUMP(prompt)// #635: ;// #636: ;// #637: ;**************************************************************************************// #638: ; Read StrataFLASH status register// #639: ;**************************************************************************************// #640: ;// #641: ; The main reason for reading the status register is to determine when the memory// #642: ; is ready or busy. This information is provided by bit7 (0=busy and 1=ready).// #643: ;// #644: ; The lower bits all indicate errors of some kind and therefore the only desirable// #645: ; response is 00 hex or 80 hex. In this program, no error checking or clearing// #646: ; is performed and the way this routine is executed from the menu only 80 hex is// #647: ; expected.// #648: ;// #649: ; To read the status register the read status register command must be written to// #650: ; the device. All subsequent reads are then result in the return of the status// #651: ; register. A different read command must be written to the device to stop this// #652: ; mode.// #653: ;// #654: ; This mode is also entered automatically when performing program and erase operations.// #655: ;// @0d5 #656: [SF_status]00900 // @0d5 #656: LOAD(s9,0) ;define base address 00000000800 // @0d6 #657: LOAD(s8,0)00700 // @0d7 #658: LOAD(s7,0)00170 // @0d8 #659: LOAD(s1,112) ;command to read status register300ea // @0d9 #660: CALL(SF_byte_write)30193 // @0da #661: CALL(send_CR)300e0 // @0db #662: CALL(SF_byte_read) ;read status register into s030167 // @0dc #663: CALL(send_hex_byte) ;display byte30193 // @0dd #664: CALL(send_CR)300f4 // @0de #665: CALL(set_SF_read_array_mode)34007 // @0df #666: JUMP(prompt)// #667: ;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?