📄 fc_ctrl.psm
字号:
CALL LCD_write_data
LOAD s5, character_0
CALL LCD_write_data
RETURN
;
;
;Display 'SMA input' at current cursor position
;
;
disp_SMA_input: LOAD s5, character_S
CALL LCD_write_data
LOAD s5, character_M
CALL LCD_write_data
LOAD s5, character_A
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_i
CALL LCD_write_data
LOAD s5, character_n
CALL LCD_write_data
LOAD s5, character_p
CALL LCD_write_data
LOAD s5, character_u
CALL LCD_write_data
LOAD s5, character_t
CALL LCD_write_data
LOAD sF, 06
JUMP disp_spaces
;
;
;
;Display '50MHz Crystal' at current cursor position
;
;
disp_50MHz_Crystal: LOAD s5, character_5
CALL LCD_write_data
LOAD s5, character_0
CALL LCD_write_data
LOAD s5, character_M
CALL LCD_write_data
LOAD s5, character_H
CALL LCD_write_data
LOAD s5, character_z
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_C
CALL LCD_write_data
LOAD s5, character_r
CALL LCD_write_data
LOAD s5, character_y
CALL LCD_write_data
LOAD s5, character_s
CALL LCD_write_data
LOAD s5, character_t
CALL LCD_write_data
LOAD s5, character_a
CALL LCD_write_data
LOAD s5, character_l
CALL LCD_write_data
LOAD sF, 02
JUMP disp_spaces
;
;
;
;Display 'DCM oscillator' at current cursor position
;
;
disp_DCM_Oscillator: LOAD s5, character_D
CALL LCD_write_data
LOAD s5, character_C
CALL LCD_write_data
LOAD s5, character_M
CALL LCD_write_data
disp_Oscillator: LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_O
CALL LCD_write_data
LOAD s5, character_s
CALL LCD_write_data
LOAD s5, character_c
CALL LCD_write_data
LOAD s5, character_i
CALL LCD_write_data
LOAD s5, character_l
CALL LCD_write_data
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
LOAD s5, character_space
CALL LCD_write_data
RETURN
;
;
;
;Display 'Ring oscillator' at current cursor position
;
;
disp_Ring_Oscillator: LOAD s5, character_R
CALL LCD_write_data
LOAD s5, character_i
CALL LCD_write_data
LOAD s5, character_n
CALL LCD_write_data
LOAD s5, character_g
CALL LCD_write_data
JUMP disp_Oscillator
;
;
;Display spaces at current cursor position
;Number of spaces to be specified in register sF
;
disp_spaces: COMPARE sF, 00
RETURN Z
LOAD s5, character_space
CALL LCD_write_data
SUB sF, 01
JUMP disp_spaces
;
;Display switch setting menu on entire display.
;
disp_menu: LOAD s5, 10 ;Line 1 position 0
CALL LCD_cursor
LOAD s5, character_R
CALL LCD_write_data
LOAD s5, character_i
CALL LCD_write_data
LOAD s5, character_n
CALL LCD_write_data
LOAD s5, character_g
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_D
CALL LCD_write_data
LOAD s5, character_C
CALL LCD_write_data
LOAD s5, character_M
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_5
CALL LCD_write_data
LOAD s5, character_0
CALL LCD_write_data
LOAD s5, character_M
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_S
CALL LCD_write_data
LOAD s5, character_M
CALL LCD_write_data
LOAD s5, character_A
CALL LCD_write_data
LOAD s5, 20 ;Line 2 position 0
CALL LCD_cursor
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_S
CALL LCD_write_data
LOAD s5, character_W
CALL LCD_write_data
LOAD s5, character_3
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_S
CALL LCD_write_data
LOAD s5, character_W
CALL LCD_write_data
LOAD s5, character_2
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_S
CALL LCD_write_data
LOAD s5, character_W
CALL LCD_write_data
LOAD s5, character_1
CALL LCD_write_data
LOAD s5, character_space
CALL LCD_write_data
LOAD s5, character_S
CALL LCD_write_data
LOAD s5, character_W
CALL LCD_write_data
LOAD s5, character_0
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
RETURN
;
;Delay of 20ms.
;
;Delay of 20ms used during initialisation.
;
;Registers used s0, s1, s2, s3
;
delay_20ms: LOAD s3, 14 ;20 x 1ms = 20ms
wait_20ms: CALL delay_1ms
SUB s3, 01
JUMP NZ, wait_20ms
RETURN
;
;Delay of approximately 1 second.
;
;Registers used s0, s1, s2, s3, s4
;
delay_1s: LOAD s4, 32 ;50 x 20ms = 1000ms
wait_1s: CALL delay_20ms
SUB s4, 01
JUMP NZ, wait_1s
RETURN
;
;
;
;**************************************************************************************
;LCD Character Module Routines
;**************************************************************************************
;
;LCD module is a 16 character by 2 line display but all displays are very similar
;The 4-wire data interface will be used (DB4 to DB7).
;
;The LCD modules are relatively slow and software delay loops are used to slow down
;KCPSM3 adequately for the LCD to communicate. The delay routines are provided in
;a different section (see above in this case).
;
;
;Pulse LCD enable signal 'E' high for greater than 230ns (1us is used).
;
;Register s4 should define the current state of the LCD output port.
;
;Registers used s0, s4
;
LCD_pulse_E: XOR s4, LCD_E ;E=1
OUTPUT s4, LCD_output_port
CALL delay_1us
XOR s4, LCD_E ;E=0
OUTPUT s4, LCD_output_port
RETURN
;
;Write 4-bit instruction to LCD display.
;
;The 4-bit instruction should be provided in the upper 4-bits of register s4.
;Note that this routine does not release the master enable but as it is only
;used during initialisation and as part of the 8-bit instruction write it
;should be acceptable.
;
;Registers used s4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -