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

📄 fc_ctrl.psm

📁 晶振频率实时显示在LCD上,包含LCD驱动等程序.
💻 PSM
📖 第 1 页 / 共 4 页
字号:
                      ;KCPSM3 Program - FC_CTRL
                      ;
                      ;Frequency Generator Control
                      ;Calculates and displays results on the 16x2 LCD display.
                      ;
                      ;
                      ; Version : 1.12
                      ; Date : 28th February 2006
                      ;
                      ; Ken Chapman
                      ; Xilinx Ltd
                      ;
                      ; chapman@xilinx.com
                      ;
                      ;
                      ;
                      ;**************************************************************************************
                      ;Port definitions
                      ;**************************************************************************************
                      ;
                      CONSTANT A_count0_port, 00          ;32-bit A-counter (LSByte first)
                      CONSTANT A_count1_port, 10
                      CONSTANT A_count2_port, 20
                      CONSTANT A_count3_port, 30
                      ;
                      CONSTANT B_count0_port, 40          ;32-bit B-counter (LSByte first)
                      CONSTANT B_count1_port, 50
                      CONSTANT B_count2_port, 60
                      CONSTANT B_count3_port, 70
                      ;
                      CONSTANT status_port, 80            ;4 switches and counter status
                      CONSTANT switch0, 01                ;  Switches      SW0 - bit0
                      CONSTANT switch1, 02                ; active High    SW1 - bit1
                      CONSTANT switch2, 04                ;                SW2 - bit2
                      CONSTANT switch3, 08                ;                SW3 - bit3
                      CONSTANT AB_switch, 10              ;  0=A-count enabled 1=B-count enabled
                      ;
                      ;
                      CONSTANT count_resetport, 02        ;Reset frequency counter controls
                      CONSTANT a_count_reset, 01          ;  A-count = bit0
                      CONSTANT b_count_reset, 02          ;  B-count = bit1
                      ;
                      CONSTANT LED_port, 01               ;8 simple LEDs - active high
                      ;
                      ;
                      CONSTANT source_control_port, 08    ;Select and control test sources
                      CONSTANT source_sel0, 01            ;  00 = SMA clock  01=50MHz
                      CONSTANT source_sel1, 02            ;  10 = DCM Osc    11=Ring Osc
                      CONSTANT ring_reset, 40             ; active High rest of ring osc - bit6
                      CONSTANT dcm_kick, 80               ; DCM kick start signal - bit7
                      ;
                      ;
                      ;LCD interface ports
                      ;
                      ;The master enable signal is not used by the LCD display itself
                      ;but may be required to confirm that LCD communication is active.
                      ;This is required on the Spartan-3E Starter Kit if the StrataFLASH
                      ;is used because it shares the same data pins and conflicts must be avoided.
                      ;
                      CONSTANT LCD_output_port, 04        ;LCD character module output data and control
                      CONSTANT LCD_E, 01                  ;   active High Enable        E - bit0
                      CONSTANT LCD_RW, 02                 ;   Read=1 Write=0           RW - bit1
                      CONSTANT LCD_RS, 04                 ;   Instruction=0 Data=1     RS - bit2
                      CONSTANT LCD_drive, 08              ;   Master enable (active High) - bit3
                      CONSTANT LCD_DB4, 10                ;   4-bit              Data DB4 - bit4
                      CONSTANT LCD_DB5, 20                ;   interface          Data DB5 - bit5
                      CONSTANT LCD_DB6, 40                ;                      Data DB6 - bit6
                      CONSTANT LCD_DB7, 80                ;                      Data DB7 - bit7
                      ;
                      ;
                      CONSTANT LCD_input_port, 09         ;LCD character module input data
                      CONSTANT LCD_read_spare0, 01        ;    Spare bits               - bit0
                      CONSTANT LCD_read_spare1, 02        ;    are zero                 - bit1
                      CONSTANT LCD_read_spare2, 04        ;                             - bit2
                      CONSTANT LCD_read_spare3, 08        ;                             - bit3
                      CONSTANT LCD_read_DB4, 10           ;    4-bit           Data DB4 - bit4
                      CONSTANT LCD_read_DB5, 20           ;    interface       Data DB5 - bit5
                      CONSTANT LCD_read_DB6, 40           ;                    Data DB6 - bit6
                      CONSTANT LCD_read_DB7, 80           ;                    Data DB7 - bit7
                      ;
                      ;
                      ;
                      ;Special Register usage
                      ;
                      ;
                      ;
                      ;**************************************************************************************
                      ;Scratch Pad Memory Locations
                      ;**************************************************************************************
                      ;
                      ;
                      CONSTANT count0, 00                 ;last 32-bit counter value (LSByte first)
                      CONSTANT count1, 01
                      CONSTANT count2, 02
                      CONSTANT count3, 03
                      ;
                      CONSTANT ISR_count, 04              ;count number of interrupts for a clean start
                      ;
                      CONSTANT decimal0, 11               ;10 digit decimal value up to 4,294,967,295
                      CONSTANT decimal1, 12
                      CONSTANT decimal2, 13
                      CONSTANT decimal3, 14
                      CONSTANT decimal4, 15
                      CONSTANT decimal5, 16
                      CONSTANT decimal6, 17
                      CONSTANT decimal7, 18
                      CONSTANT decimal8, 19
                      CONSTANT decimal9, 1A
                      ;
                      ;
                      ;
                      CONSTANT preserve_s0, 30            ;place to save register contents
                      CONSTANT preserve_s1, 31
                      CONSTANT preserve_s2, 32
                      CONSTANT preserve_s3, 33
                      CONSTANT preserve_s4, 34
                      CONSTANT preserve_s5, 35
                      CONSTANT preserve_s6, 36
                      CONSTANT preserve_s7, 37
                      CONSTANT preserve_s8, 38
                      CONSTANT preserve_s9, 39
                      CONSTANT preserve_sA, 3A
                      CONSTANT preserve_sB, 3B
                      CONSTANT preserve_sC, 3C
                      CONSTANT preserve_sD, 3D
                      CONSTANT preserve_sE, 3E
                      CONSTANT preserve_sF, 3F
                      ;
                      ;
                      ;
                      ;**************************************************************************************
                      ;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_stop, 2E
                      CONSTANT character_semi_colon, 3B
                      CONSTANT character_minus, 2D
                      CONSTANT character_divide, 2F       ;'/'
                      CONSTANT character_plus, 2B
                      CONSTANT character_comma, 2C
                      CONSTANT character_less_than, 3C
                      CONSTANT character_greater_than, 3E
                      CONSTANT character_equals, 3D
                      CONSTANT character_space, 20
                      CONSTANT character_CR, 0D           ;carriage return
                      CONSTANT character_question, 3F     ;'?'
                      CONSTANT character_dollar, 24
                      CONSTANT character_exclaim, 21      ;'!'
                      CONSTANT character_BS, 08           ;Back Space command character
                      ;
                      ;
                      ;
                      ;
                      ;
                      ;**************************************************************************************
                      ;Initialise the system
                      ;**************************************************************************************
                      ;
          cold_start: CALL LCD_reset                      ;initialise LCD display
                      LOAD s0, 00                         ;Turn off LEDs
                      OUTPUT s0, LED_port
                      ;
                      ;
                      ;Write welcome message to LCD display
                      ;
                      LOAD s5, 10                         ;Line 1 position 0
                      CALL LCD_cursor
                      CALL disp_PicoBlaze                 ;Display 'PicoBlaze Inside'
                      CALL delay_1s                       ;wait 3 seconds
                      CALL delay_1s
                      CALL delay_1s
                      LOAD s5, 10                         ;Line 1 position 0
                      CALL LCD_cursor
                      CALL disp_Frequency                 ;Display 'Frequency Counter V1.00'
                      LOAD s5, 21                         ;Line 2 position 1
                      CALL LCD_cursor
                      CALL disp_Counter
                      LOAD s5, 2B                         ;Line 2 position 11
                      CALL LCD_cursor
                      CALL disp_version
                      CALL delay_1s                       ;wait 5 seconds
                      CALL delay_1s
                      CALL delay_1s
                      CALL delay_1s
                      CALL delay_1s
                      CALL LCD_clear                      ;Clear display
                      ;
                      ;Kick start the DCM oscillator.
                      ; Just requires a few cyles of activity
                      ;
                      LOAD s0, FF
                      LOAD s1, 00
           kick_loop: OUTPUT s1, source_control_port
                      XOR s1, dcm_kick                    ;toggle kick start signal
                      SUB s0, 01
                      JUMP NZ, kick_loop
                      ;
                      ;clear all scratch pad memory locations
                      ;
                      LOAD s1, 3F
                      LOAD s0, 00
           clear_spm: STORE s0, (s1)
                      SUB s1, 01
                      JUMP NC, clear_spm
                      ;
                      ENABLE INTERRUPT
                      ;
                      ;**************************************************************************************
                      ;Main Program
                      ;**************************************************************************************
                      ;
                      ;The task of the main program is just to read the most recent values from
                      ;scratch pad memory and display them as fast as it can.
                      ;
                      ;It also reads the slide switches controls the selection of the source frequency to
                      ;be measured.
                      ;
          warm_start: LOAD s5, 21                         ;Line 2 position 1

⌨️ 快捷键说明

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