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

📄 control.psm

📁 和picoblaze完全兼容的mcu ip core
💻 PSM
📖 第 1 页 / 共 5 页
字号:
                          ; KCPSM3 Program - Communication with DS2432 secure memory on the Spartan-3E Starter Kit.
                          ;
                          ; Ken Chapman - Xilinx Ltd
                          ;
                          ; Version v1.00 - 5th April 2006
                          ;
                          ; This program uses a 9600 baud UART connection to allow communication with the
                          ; 1-wire interface of the DS2432 memory device from Dallas Semiconductor.
                          ;
                          ; The program only supports a limited number of the DS2432 commands but is intended
                          ; to guide you through the state machine of the device as well as show how
                          ; 1-wire communication is achieved. The DS2432 also uses 8 and 16 bits CRC checks and
                          ; this program includes these calculations to validate the communications.
                          ;
                          ; Commands supported include read ROM, write scratchpad memory and read scratchpad
                          ; memory. These allow you to confirm the ability to both read and write data but
                          ; at no time modify the actual EEPROM secure memory or secret.
                          ;
                          ; There are then two manual commands which allow you to write any byte value that
                          ; you enter and to read a byte from the DS2432 device. At this point you are free
                          ; to experiment and this may result in the device contents being altered. You also
                          ; become responsible for tracking the states but remember that a master reset will
                          ; always return you to a known starting point again.
                          ;
                          ;
                          ;**************************************************************************************
                          ; Port definitions
                          ;**************************************************************************************
                          ;
                          ;
                          CONSTANT status_port, 00               ;UART status input
                          CONSTANT tx_half_full, 01              ;  Transmitter     half full - bit0
                          CONSTANT tx_full, 02                   ;    FIFO               full - bit1
                          CONSTANT rx_data_present, 04           ;  Receiver     data present - bit2
                          CONSTANT rx_half_full, 08              ;    FIFO          half full - bit3
                          CONSTANT rx_full, 10                   ;                   full - bit4
                          CONSTANT spare1, 20                    ;                  spare '0' - bit5
                          CONSTANT spare2, 40                    ;                  spare '0' - bit6
                          CONSTANT spare3, 80                    ;                  spare '0' - bit7
                          ;
                          CONSTANT UART_read_port, 01            ;UART Rx data input
                          ;
                          CONSTANT UART_write_port, 04           ;UART Tx data output
                          ;
                          ;
                          CONSTANT DS_wire_in_port, 02           ;Read signal from DS2432 device
                          CONSTANT DS_wire_out_port, 08          ;Drive signal to DS2432 device (open collector)
                          CONSTANT DS_wire, 01                   ;       Signal is bit0 in both cases
                          ;
                          ;
                          ;
                          ;
                          ;**************************************************************************************
                          ; Special Register usage
                          ;**************************************************************************************
                          ;
                          NAMEREG sF, UART_data                  ;used to pass data to and from the UART
                          ;
                          ;
                          ;**************************************************************************************
                          ; Scratch Pad Memory Locations
                          ;**************************************************************************************
                          ;
                          ; Scratch pad memory provides 64 bytes in the address range 00 to 3F hex.
                          ;
                          ;
                          ; Locations for device family code, serial number and 8-bit CRC value
                          ;
                          CONSTANT family_code, 00
                          CONSTANT serial_number0, 01            ;48-bit serial number LS-Byte first
                          CONSTANT serial_number1, 02
                          CONSTANT serial_number2, 03
                          CONSTANT serial_number3, 04
                          CONSTANT serial_number4, 05
                          CONSTANT serial_number5, 06
                          CONSTANT read_ROM_CRC, 07              ;8-bit CRC
                          ;
                          ;
                          ; Locations to store all bytes in a command communication for 16-bit CRC calculation
                          ;
                          CONSTANT command_start, 08
                          ;
                          ;
                          ;**************************************************************************************
                          ; Useful data constants
                          ;**************************************************************************************
                          ;
                          ; Constant to define a software delay of 1us. This must be adjusted to reflect the
                          ; clock applied to KCPSM3. Every instruction executes in 2 clock cycles making the
                          ; calculation highly predictable. The '6' in the following equation even allows for
                          ; 'CALL delay_1us' instruction in the initiating code.
                          ;
                          ; delay_1us_constant =  (clock_rate - 6)/4       Where 'clock_rate' is in MHz
                          ;
                          ; Example: For a 50MHz clock the constant value is (10-6)/4 = 11  (0B Hex).
                          ; For clock rates below 10MHz the value of 1 must be used and the operation will
                          ; become lower than intended.
                          ;
                          CONSTANT delay_1us_constant, 0B
                          ;
                          ;
                          ;
                          ;ASCII table
                          ;
                          CONSTANT character_a, 61
                          CONSTANT character_b, 62
                          CONSTANT character_c, 63
                          CONSTANT character_d, 64
                          CONSTANT character_e, 65
                          CONSTANT character_f, 66
                          CONSTANT character_g, 67
                          CONSTANT character_h, 68
                          CONSTANT character_i, 69
                          CONSTANT character_j, 6A
                          CONSTANT character_k, 6B
                          CONSTANT character_l, 6C
                          CONSTANT character_m, 6D
                          CONSTANT character_n, 6E
                          CONSTANT character_o, 6F
                          CONSTANT character_p, 70
                          CONSTANT character_q, 71
                          CONSTANT character_r, 72
                          CONSTANT character_s, 73
                          CONSTANT character_t, 74
                          CONSTANT character_u, 75
                          CONSTANT character_v, 76
                          CONSTANT character_w, 77
                          CONSTANT character_x, 78
                          CONSTANT character_y, 79
                          CONSTANT character_z, 7A
                          CONSTANT character_A, 41
                          CONSTANT character_B, 42
                          CONSTANT character_C, 43
                          CONSTANT character_D, 44
                          CONSTANT character_E, 45
                          CONSTANT character_F, 46
                          CONSTANT character_G, 47
                          CONSTANT character_H, 48
                          CONSTANT character_I, 49
                          CONSTANT character_J, 4A
                          CONSTANT character_K, 4B
                          CONSTANT character_L, 4C
                          CONSTANT character_M, 4D
                          CONSTANT character_N, 4E
                          CONSTANT character_O, 4F
                          CONSTANT character_P, 50
                          CONSTANT character_Q, 51
                          CONSTANT character_R, 52
                          CONSTANT character_S, 53
                          CONSTANT character_T, 54
                          CONSTANT character_U, 55
                          CONSTANT character_V, 56
                          CONSTANT character_W, 57
                          CONSTANT character_X, 58
                          CONSTANT character_Y, 59
                          CONSTANT character_Z, 5A
                          CONSTANT character_0, 30
                          CONSTANT character_1, 31
                          CONSTANT character_2, 32
                          CONSTANT character_3, 33
                          CONSTANT character_4, 34
                          CONSTANT character_5, 35
                          CONSTANT character_6, 36
                          CONSTANT character_7, 37
                          CONSTANT character_8, 38
                          CONSTANT character_9, 39
                          CONSTANT character_colon, 3A
                          CONSTANT character_fullstop, 2E
                          CONSTANT character_semi_colon, 3B
                          CONSTANT character_minus, 2D
                          CONSTANT character_plus, 2B
                          CONSTANT character_comma, 2C
                          CONSTANT character_less_than, 3C       ;'<'
                          CONSTANT character_greater_than, 3E    ;'>'
                          CONSTANT character_open, 28            ;'('
                          CONSTANT character_close, 29           ;')'
                          CONSTANT character_divide, 2F          ;'/'
                          CONSTANT character_equals, 3D
                          CONSTANT character_space, 20
                          CONSTANT character_CR, 0D              ;carriage return
                          CONSTANT character_LF, 0A              ;line feed
                          CONSTANT character_question, 3F        ;'?'
                          CONSTANT character_dollar, 24
                          CONSTANT character_exclaim, 21         ;'!'
                          CONSTANT character_BS, 08              ;Back Space command character
                          CONSTANT character_XON, 11             ;Flow control ON
                          CONSTANT character_XOFF, 13            ;Flow control OFF
                          ;
                          ;
                          ;**************************************************************************************
                          ; Initialise the system and welcome message
                          ;**************************************************************************************
                          ;
              cold_start: CALL DS_wire_init                      ;Ensure DS_wire is not driven (pulled High)
                          CALL delay_1s                          ;Allow everything to settle!

⌨️ 快捷键说明

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