⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 control.rmh

📁 和picoblaze完全兼容的mcu ip core
💻 RMH
📖 第 1 页 / 共 5 页
字号:
// #57: NAMEREG(sF,UART_data) ;used to pass data to and from the UART// #58: ;// #59: ;// #60: ;**************************************************************************************// #61: ; Scratch Pad Memory Locations// #62: ;**************************************************************************************// #63: ;// #64: ; Scratch pad memory provides 64 bytes in the address range 00 to 3F hex.// #65: ;// #66: ;// #67: ; Locations for device family code, serial number and 8-bit CRC value// #68: ;// #69: CONSTANT(family_code,0)// #70: CONSTANT(serial_number0,1) ;48-bit serial number LS-Byte first// #71: CONSTANT(serial_number1,2)// #72: CONSTANT(serial_number2,3)// #73: CONSTANT(serial_number3,4)// #74: CONSTANT(serial_number4,5)// #75: CONSTANT(serial_number5,6)// #76: CONSTANT(read_ROM_CRC,7) ;8-bit CRC// #77: ;// #78: ;// #79: ; Locations to store all bytes in a command communication for 16-bit CRC calculation// #80: ;// #81: CONSTANT(command_start,8)// #82: ;// #83: ;// #84: ;**************************************************************************************// #85: ; Useful data constants// #86: ;**************************************************************************************// #87: ;// #88: ; Constant to define a software delay of 1us. This must be adjusted to reflect the// #89: ; clock applied to KCPSM3. Every instruction executes in 2 clock cycles making the// #90: ; calculation highly predictable. The '6' in the following equation even allows for// #91: ; 'CALL delay_1us' instruction in the initiating code.// #92: ;// #93: ; delay_1us_constant =  (clock_rate - 6)/4       Where 'clock_rate' is in MHz// #94: ;// #95: ; Example: For a 50MHz clock the constant value is (10-6)/4 = 11  (0B Hex).// #96: ; For clock rates below 10MHz the value of 1 must be used and the operation will// #97: ; become lower than intended.// #98: ;// #99: CONSTANT(delay_1us_constant,11)// #100: ;// #101: ;// #102: ;// #103: ;ASCII table// #104: ;// #105: CONSTANT(character_a,97)// #106: CONSTANT(character_b,98)// #107: CONSTANT(character_c,99)// #108: CONSTANT(character_d,100)// #109: CONSTANT(character_e,101)// #110: CONSTANT(character_f,102)// #111: CONSTANT(character_g,103)// #112: CONSTANT(character_h,104)// #113: CONSTANT(character_i,105)// #114: CONSTANT(character_j,106)// #115: CONSTANT(character_k,107)// #116: CONSTANT(character_l,108)// #117: CONSTANT(character_m,109)// #118: CONSTANT(character_n,110)// #119: CONSTANT(character_o,111)// #120: CONSTANT(character_p,112)// #121: CONSTANT(character_q,113)// #122: CONSTANT(character_r,114)// #123: CONSTANT(character_s,115)// #124: CONSTANT(character_t,116)// #125: CONSTANT(character_u,117)// #126: CONSTANT(character_v,118)// #127: CONSTANT(character_w,119)// #128: CONSTANT(character_x,120)// #129: CONSTANT(character_y,121)// #130: CONSTANT(character_z,122)// #131: CONSTANT(character_A,65)// #132: CONSTANT(character_B,66)// #133: CONSTANT(character_C,67)// #134: CONSTANT(character_D,68)// #135: CONSTANT(character_E,69)// #136: CONSTANT(character_F,70)// #137: CONSTANT(character_G,71)// #138: CONSTANT(character_H,72)// #139: CONSTANT(character_I,73)// #140: CONSTANT(character_J,74)// #141: CONSTANT(character_K,75)// #142: CONSTANT(character_L,76)// #143: CONSTANT(character_M,77)// #144: CONSTANT(character_N,78)// #145: CONSTANT(character_O,79)// #146: CONSTANT(character_P,80)// #147: CONSTANT(character_Q,81)// #148: CONSTANT(character_R,82)// #149: CONSTANT(character_S,83)// #150: CONSTANT(character_T,84)// #151: CONSTANT(character_U,85)// #152: CONSTANT(character_V,86)// #153: CONSTANT(character_W,87)// #154: CONSTANT(character_X,88)// #155: CONSTANT(character_Y,89)// #156: CONSTANT(character_Z,90)// #157: CONSTANT(character_0,48)// #158: CONSTANT(character_1,49)// #159: CONSTANT(character_2,50)// #160: CONSTANT(character_3,51)// #161: CONSTANT(character_4,52)// #162: CONSTANT(character_5,53)// #163: CONSTANT(character_6,54)// #164: CONSTANT(character_7,55)// #165: CONSTANT(character_8,56)// #166: CONSTANT(character_9,57)// #167: CONSTANT(character_colon,58)// #168: CONSTANT(character_fullstop,46)// #169: CONSTANT(character_semi_colon,59)// #170: CONSTANT(character_minus,45)// #171: CONSTANT(character_plus,43)// #172: CONSTANT(character_comma,44)// #173: CONSTANT(character_less_than,60) ;'<'// #174: CONSTANT(character_greater_than,62) ;'>'// #175: CONSTANT(character_open,40) ;'('// #176: CONSTANT(character_close,41) ;')'// #177: CONSTANT(character_divide,47) ;'/'// #178: CONSTANT(character_equals,61)// #179: CONSTANT(character_space,32)// #180: CONSTANT(character_CR,13) ;carriage return// #181: CONSTANT(character_LF,10) ;line feed// #182: CONSTANT(character_question,63) ;'?'// #183: CONSTANT(character_dollar,36)// #184: CONSTANT(character_exclaim,33) ;'!'// #185: CONSTANT(character_BS,8) ;Back Space command character// #186: CONSTANT(character_XON,17) ;Flow control ON// #187: CONSTANT(character_XOFF,19) ;Flow control OFF// #188: ;// #189: ;// #190: ;**************************************************************************************// #191: ; Initialise the system and welcome message// #192: ;**************************************************************************************// #193: ;// @000 #194: [cold_start]30143 // @000 #194: CALL(DS_wire_init) ;Ensure DS_wire is not driven (pulled High)301ad // @001 #195: CALL(delay_1s) ;Allow everything to settle!// @002 #196: [welcome_start]30228 // @002 #196: CALL(send_welcome) ;start up message and version number// #197: ;// #198: ;// #199: ;// #200: ; The main program guides the user to follow the command state machine of the// #201: ; DS2432 device by only offering those choices that are valid at each stage.// #202: ; This program only offers a limited choice and it is left as an exercise to// #203: ; the user to modify or expand this choice as required.// #204: ;// #205: ;**************************************************************************************// #206: ; Reset Main menu and command selection// #207: ;**************************************************************************************// #208: ;// #209: ; Initially the only action available is a master reset and test for a presence// #210: ; pulse response from the DS2432.// #211: ;// @003 #212: [reset_menu]3026f // @003 #212: CALL(send_reset_menu) ;Menu and command selection3021f // @004 #213: CALL(send_CR)// #214: ;// @005 #215: [reset_prompt]30033 // @005 #215: CALL(menu_prompt) ;prompt for user input14048 // @006 #216: COMPARE(s0,character_H) ;test for commands and execute as required35003 // @007 #217: JUMP(Z,reset_menu)14031 // @008 #218: COMPARE(s0,character_1)3500c // @009 #219: JUMP(Z,master_reset_regular)30039 // @00a #220: CALL(no_valid_input)34005 // @00b #221: JUMP(reset_prompt) ;Try again!// #222: ;// #223: ; The master reset should result in a presence pulse.// #224: ; This will be reported and control passed to the appropriate// #225: ; menu in the sequence.// #226: ;// @00c #227: [master_reset_regular]3021f // @00c #227: CALL(send_CR)30146 // @00d #228: CALL(DS_init_regular_mode)35c11 // @00e #229: JUMP(NC,reset_passed) ;test for presence pulse3034d // @00f #230: CALL(send_Fail)34003 // @010 #231: JUMP(reset_menu) ;fail stays in reset menu// @011 #232: [reset_passed]30345 // @011 #232: CALL(send_Pass) ;pass progresses to ROM menu34013 // @012 #233: JUMP(ROM_menu)// #234: ;// #235: ; After a valid master reset, the only commands available are the ROM// #236: ; commands of which only Read ROM and Skip ROM are currently supported.// #237: ; Another master reset can be issued is so desired.// #238: ;// @013 #239: [ROM_menu]30278 // @013 #239: CALL(send_ROM_menu) ;Menu and command selection3021f // @014 #240: CALL(send_CR)// #241: ;// @015 #242: [ROM_prompt]30033 // @015 #242: CALL(menu_prompt) ;prompt for user input14048 // @016 #243: COMPARE(s0,character_H) ;test for commands and execute as required35013 // @017 #244: JUMP(Z,ROM_menu)14031 // @018 #245: COMPARE(s0,character_1)3500c // @019 #246: JUMP(Z,master_reset_regular) ;repeat reset as before14032 // @01a #247: COMPARE(s0,character_2)3503f // @01b #248: JUMP(Z,read_ROM_command)14033 // @01c #249: COMPARE(s0,character_3)35062 // @01d #250: JUMP(Z,skip_ROM_command)30039 // @01e #251: CALL(no_valid_input)34015 // @01f #252: JUMP(ROM_prompt) ;Try again!// #253: ;// #254: ;// #255: ;// #256: ; After a valid ROM command the DS2432 specific memory commands and SHA-1// #257: ; functions become accessible. Each of these end with the DS2432 returned// #258: ; back to the waiting for ROM command state completing the menu sequence.// #259: ;// @020 #260: [DS2432_menu]30293 // @020 #260: CALL(send_DS2432_menu) ;Menu and command selection3021f // @021 #261: CALL(send_CR)// #262: ;// @022 #263: [DS2432_prompt]30033 // @022 #263: CALL(menu_prompt) ;prompt for user input14048 // @023 #264: COMPARE(s0,character_H) ;test for commands and execute as required35020 // @024 #265: JUMP(Z,DS2432_menu)14031 // @025 #266: COMPARE(s0,character_1)3500c // @026 #267: JUMP(Z,master_reset_regular) ;repeat reset as before14032 // @027 #268: COMPARE(s0,character_2)35066 // @028 #269: JUMP(Z,read_memory_command)14033 // @029 #270: COMPARE(s0,character_3)35081 // @02a #271: JUMP(Z,write_scratchpad_command)14034 // @02b #272: COMPARE(s0,character_4)350d4 // @02c #273: JUMP(Z,read_scratchpad_command)14035 // @02d #274: COMPARE(s0,character_5)350c3 // @02e #275: JUMP(Z,write_byte_command)14036 // @02f #276: COMPARE(s0,character_6)350cc // @030 #277: JUMP(Z,read_byte_command)30039 // @031 #278: CALL(no_valid_input)34022 // @032 #279: JUMP(DS2432_prompt) ;Try again!// #280: ;// #281: ;// #282: ;// #283: ;// #284: ;// #285: ;**************************************************************************************// #286: ; Prompt and selection tasks used in menus.// #287: ;**************************************************************************************// #288: ;// #289: ; Prompts for input with > character and waits for key stroke which is// #290: ; returned in upper case in register s0// #291: ;// @033 #292: [menu_prompt]3021f // @033 #292: CALL(send_CR)3021f // @034 #293: CALL(send_CR)00f3e // @035 #294: LOAD(UART_data,character_greater_than) ;prompt for input301b8 // @036 #295: CALL(send_to_UART)30214 // @037 #296: CALL(read_upper_case)2a000 // @038 #297: RETURN// #298: ;// @039 #299: [no_valid_input]3021f // @039 #299: CALL(send_CR) ;no valid command input00f3f // @03a #300: LOAD(UART_data,character_question) ;display ???301b8 // @03b #301: CALL(send_to_UART)301b8 // @03c #302: CALL(send_to_UART)301b8 // @03d #303: CALL(send_to_UART)2a000 // @03e #304: RETURN// #305: ;// #306: ;// #307: ;**************************************************************************************// #308: ; DS2432 Read ROM Command.// #309: ;**************************************************************************************// #310: ;// #311: ; The read ROM command (33 hex) allows the 8-bit family code, 48-bit unique serial// #312: ; number and 8-bit CRC to be read from the DS2432 device.// #313: ;// #314: ; This routine reads the values and places them in KCPSM3 scratch pad memory// #315: ; locations for future reference. These locations should be defined with constants// #316: ; as follows and MUST be in consecutive ascending locations.// #317: ;// #318: ;  family_code// #319: ;     Location to store family code which should be 33 hex// #320: ;  serial_number0 to serial_number5// #321: ;     6 bytes to hold 48-bit serial number (LS-byte first).// #322: ;  read_ROM_CRC// #323: ;     8-bit CRC value for the above data.// #324: ;// #325: ;// #326: ; The routine also displays the values read and performs a verification of the// #327: ; 8-bit CRC displaying a 'pass' or 'fail' message as appropriate.// #328: ;// @03f #329: [read_ROM_command]00333 // @03f #329: LOAD(s3,51) ;Read ROM Command30161 // @040 #330: CALL(write_byte_slow) ;transmit command00500 // @041 #331: LOAD(s5,family_code) ;memory pointer// @042 #332: [read_ROM_loop]30182 // @042 #332: CALL(read_byte_slow) ;read response into s32f350 // @043 #333: STORE(s3,s5) ;store value14507 // @044 #334: COMPARE(s5,read_ROM_CRC) ;8-bytes to read35048 // @045 #335: JUMP(Z,display_ROM)18501 // @046 #336: ADD(s5,1)34042 // @047 #337: JUMP(read_ROM_loop)// @048 #338: [display_ROM]3021f // @048 #338: CALL(send_CR)30386 // @049 #339: CALL(send_code) ;'code=' to display family code06000 // @04a #340: FETCH(s0,family_code)301ee // @04b #341: CALL(send_hex_byte)

⌨️ 快捷键说明

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