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

📄 lcd.psm

📁 PicoBlaze的开发压缩包,PicoBlaze的编译器.
💻 PSM
📖 第 1 页 / 共 3 页
字号:
                       ;
                       ; The value is displayed in the format      xxx.xxx xxxMHz
                       ;
                       ; However, the most significant 2 digits will be blanked if zero.
                       ;
                       ; registers used s0,s1,s2,s3,s4,s5,s6,s7
                       ;
                       ;
        	       ;
     display_3_digits: LOAD s3, 03                         ;3 digits to display
          3digit_loop: FETCH s5, (s2)
                       CALL display_digit
                       SUB s2, 01                          ;decrement digit pointer
                       SUB s3, 01                          ;count digits displayed
                       JUMP NZ, 3digit_loop
                       RETURN
                       ;
        display_digit: ADD s5, 30                          ;convert BCD to ASCII character
                       CALL LCD_write_data
                       RETURN
                       ;
        display_space: LOAD s5, character_space
                       CALL LCD_write_data
                       RETURN
                       ;
                       ;
                       ;
                       ;
                       ;
                       ;**************************************************************************************
                       ; Routines to display hexadecimal values on LCD display
                       ;**************************************************************************************
                       ;
                       ;
                       ; Convert hexadecimal value provided in register s0 into ASCII characters
                       ;
                       ; The value provided must can be any value in the range 00 to FF and will be converted into
                       ; two ASCII characters.
                       ;     The upper nibble will be represented by an ASCII character returned in register s3.
                       ;     The lower nibble will be represented by an ASCII character returned in register s2.
                       ;
                       ; The ASCII representations of '0' to '9' are 30 to 39 hexadecimal which is simply 30 hex
                       ; added to the actual decimal value. The ASCII representations of 'A' to 'F' are 41 to 46
                       ; hexadecimal requiring a further addition of 07 to the 30 already added.
                       ;
                       ; Registers used s0, s2 and s3.
                       ;
    hex_byte_to_ASCII: LOAD s2, s0                         ;remember value supplied
                       SR0 s0                              ;isolate upper nibble
                       SR0 s0
                       SR0 s0
                       SR0 s0
                       CALL hex_to_ASCII                   ;convert
                       LOAD s3, s0                         ;upper nibble value in s3
                       LOAD s0, s2                         ;restore complete value
                       AND s0, 0F                          ;isolate lower nibble
                       CALL hex_to_ASCII                   ;convert
                       LOAD s2, s0                         ;lower nibble value in s2
                       RETURN
                       ;
                       ; Convert hexadecimal value provided in register s0 into ASCII character
                       ;
                       ;Register used s0
                       ;
         hex_to_ASCII: SUB s0, 0A                          ;test if value is in range 0 to 9
                       JUMP C, number_char
                       ADD s0, 07                          ;ASCII char A to F in range 41 to 46
          number_char: ADD s0, 3A                          ;ASCII char 0 to 9 in range 30 to 40
                       RETURN
                       ;
                       ;
                       ; Display the two character HEX value of the register contents 's0' on the LCD
                       ; at the current cursor position.
                       ;
                       ; Registers used s0, s1, s2, s3, s4, s5
                       ;
     display_hex_byte: CALL hex_byte_to_ASCII
                       LOAD s5, s3
                       CALL LCD_write_data
                       LOAD s5, s2
                       CALL LCD_write_data
                       RETURN
                       ;
                       ;
                       ;
                       ; Display the 32-bit value stored in 4 ascending memory locations as an 8 character
                       ; HEX value at the current cursor position. Register s7 must contain the memory
                       ; location of the most significant byte (which is also the highest address).
                       ;
                       ; Registers used s0, s1, s2, s3, s4, s5, s6, s7
                       ;
   display_hex_32_bit: LOAD s6, 04                         ;4 bytes to display
          disp32_loop: FETCH s0, (s7)                      ;read byte
                       CALL display_hex_byte               ;display byte
                       SUB s7, 01                          ;decrement pointer
                       SUB s6, 01                          ;count bytes displayed
                       RETURN Z
                       JUMP disp32_loop
                       ;
                       ;
                       ;**************************************************************************************
                       ;LCD text messages
                       ;**************************************************************************************
                       ;
                       ;
                       ;Display 'Frequency' on LCD at current cursor position
                       ;
       disp_Frequency: LOAD s5, character_F
                       CALL LCD_write_data
                       LOAD s5, character_r
                       CALL LCD_write_data
                       LOAD s5, character_e
                       CALL LCD_write_data
                       LOAD s5, character_q
                       CALL LCD_write_data
                       LOAD s5, character_u
                       CALL LCD_write_data
                       LOAD s5, character_e
                       CALL LCD_write_data
                       LOAD s5, character_n
                       CALL LCD_write_data
                       LOAD s5, character_c
                       CALL LCD_write_data
                       LOAD s5, character_y
                       CALL LCD_write_data
                       RETURN
                       ;
                       ;Display 'Generator' on LCD at current cursor position
                       ;
       disp_Generator: LOAD s5, character_G
                       CALL LCD_write_data
                       LOAD s5, character_e
                       CALL LCD_write_data
                       LOAD s5, character_n
                       CALL LCD_write_data
                       LOAD s5, character_e
                       CALL LCD_write_data
                       LOAD s5, character_r
                       CALL LCD_write_data
                       LOAD s5, character_a
                       CALL LCD_write_data
                       LOAD s5, character_t
                       CALL LCD_write_data
                       LOAD s5, character_o
                       CALL LCD_write_data
                       LOAD s5, character_r
                       CALL LCD_write_data
                       CALL display_space
                       LOAD s5, character_v
                       CALL LCD_write_data
                       LOAD s5, character_1
                       CALL LCD_write_data
                       LOAD s5, character_stop
                       CALL LCD_write_data
                       LOAD s5, character_2
                       CALL LCD_write_data
                       RETURN
                       ;
                       ;
                       ;
                       ;
                       ;**************************************************************************************
                       ;Software delay routines
                       ;**************************************************************************************
                       ;
                       ;
                       ;
                       ;Delay of 1us.
                       ;
                       ;Constant value defines reflects 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
                       ;
                       ;Registers used s0
                       ;
            delay_1us: LOAD s0, delay_1us_constant
             wait_1us: SUB s0, 01
                       JUMP NZ, wait_1us
                       RETURN
                       ;
                       ;Delay of 40us.
                       ;
                       ;Registers used s0, s1
                       ;
           delay_40us: LOAD s1, 28                         ;40 x 1us = 40us
            wait_40us: CALL delay_1us
                       SUB s1, 01
                       JUMP NZ, wait_40us
                       RETURN
                       ;
                       ;
                       ;Delay of 1ms.
                       ;
                       ;Registers used s0, s1, s2
                       ;
            delay_1ms: LOAD s2, 19                         ;25 x 40us = 1ms
             wait_1ms: CALL delay_40us
                       SUB s2, 01
                       JUMP NZ, wait_1ms

⌨️ 快捷键说明

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