?? uclock.psm
字號:
RETURN
;
;Send 'Syntax Error' to the UART
;
send_Syntax_Error: LOAD UART_data, character_S
CALL send_to_UART
LOAD UART_data, character_y
CALL send_to_UART
LOAD UART_data, character_n
CALL send_to_UART
LOAD UART_data, character_t
CALL send_to_UART
LOAD UART_data, character_a
CALL send_to_UART
LOAD UART_data, character_x
CALL send_to_UART
JUMP send_space_Error
;
;Send 'Overflow Error' to the UART
;
send_Overflow_Error: LOAD UART_data, character_O
CALL send_to_UART
LOAD UART_data, character_v
CALL send_to_UART
LOAD UART_data, character_e
CALL send_to_UART
LOAD UART_data, character_r
CALL send_to_UART
LOAD UART_data, character_f
CALL send_to_UART
LOAD UART_data, character_l
CALL send_to_UART
LOAD UART_data, character_o
CALL send_to_UART
LOAD UART_data, character_w
CALL send_to_UART
send_space_Error: CALL send_space
;
;Send 'Error' to the UART
;
send_Error: LOAD UART_data, character_E
CALL send_to_UART
LOAD UART_data, character_r
CALL send_to_UART
CALL send_to_UART
LOAD UART_data, character_o
CALL send_to_UART
LOAD UART_data, character_r
CALL send_to_UART
RETURN
;
;Send 'KCPSM3>' prompt to the UART
;
send_prompt: CALL send_CR ;start new line
LOAD UART_data, character_K
CALL send_to_UART
LOAD UART_data, character_C
CALL send_to_UART
LOAD UART_data, character_P
CALL send_to_UART
LOAD UART_data, character_S
CALL send_to_UART
LOAD UART_data, character_M
CALL send_to_UART
LOAD UART_data, character_3
CALL send_to_UART
;
;Send '>' character to the UART
;
send_greater_than: LOAD UART_data, character_greater_than
CALL send_to_UART
RETURN
;
;Send 'Invalid' string to the UART
;
send_Invalid: LOAD UART_data, character_I
CALL send_to_UART
LOAD UART_data, character_n
CALL send_to_UART
LOAD UART_data, character_v
CALL send_to_UART
LOAD UART_data, character_a
CALL send_to_UART
LOAD UART_data, character_l
CALL send_to_UART
LOAD UART_data, character_i
CALL send_to_UART
LOAD UART_data, character_d
CALL send_to_UART
RETURN
;
;Send 'Time' string to the UART
;
send_Time: LOAD UART_data, character_T
CALL send_to_UART
LOAD UART_data, character_i
CALL send_to_UART
LOAD UART_data, character_m
CALL send_to_UART
LOAD UART_data, character_e
CALL send_to_UART
RETURN
;
;Send 'Alarm' string to the UART
;
send_Alarm: LOAD UART_data, character_A
CALL send_to_UART
LOAD UART_data, character_l
CALL send_to_UART
LOAD UART_data, character_a
CALL send_to_UART
LOAD UART_data, character_r
CALL send_to_UART
LOAD UART_data, character_m
CALL send_to_UART
RETURN
;
;Send 'OFF' string to the UART
;
send_OFF: LOAD UART_data, character_O
CALL send_to_UART
LOAD UART_data, character_F
CALL send_to_UART
CALL send_to_UART
RETURN
;
;Send 'ON' string to the UART
;
send_ON: LOAD UART_data, character_O
CALL send_to_UART
LOAD UART_data, character_N
CALL send_to_UART
RETURN
;
;Send 'Active' string to the UART
;
send_Active: LOAD UART_data, character_A
CALL send_to_UART
LOAD UART_data, character_c
CALL send_to_UART
LOAD UART_data, character_t
CALL send_to_UART
LOAD UART_data, character_i
CALL send_to_UART
LOAD UART_data, character_v
CALL send_to_UART
LOAD UART_data, character_e
CALL send_to_UART
RETURN
;
;
;Convert time to ASCII string in scratch pad memory.
;
;The time to converted must be stored in 3 scratch pad memory locations as
;defined below. A register named 'store_pointer' must provide the address of
;first location.
;
; Address Data
;
; store_pointer ----> hours
; store_pointer + 1 ----> minutes
; store_pointer + 1 ----> seconds
;
;The resulting ASCII string will be stored in scratch pad memory starting at
;a location specified by a constant named 'string_start'. The string will
;take the format hh:mm:ss and end with a carriage return.
;
;Registers used s0, s1, s2 and 'store_pointer'.
;
time_to_ASCII: LOAD s2, string_start ;location for string
FETCH s0, (store_pointer) ;read hours value
CALL decimal_to_ASCII ;convert to ASCII
STORE s1, (s2) ;write hours to string
ADD s2, 01
STORE s0, (s2)
ADD s2, 01
LOAD s0, character_colon ;write ':' to string
STORE s0, (s2)
ADD s2, 01
ADD store_pointer, 01 ;move to minutes
FETCH s0, (store_pointer) ;read minutes value
CALL decimal_to_ASCII ;convert to ASCII
STORE s1, (s2) ;write minutes to string
ADD s2, 01
STORE s0, (s2)
ADD s2, 01
LOAD s0, character_colon ;write ':' to string
STORE s0, (s2)
ADD s2, 01
ADD store_pointer, 01 ;move to seconds
FETCH s0, (store_pointer) ;read seconds value
CALL decimal_to_ASCII ;convert to ASCII
STORE s1, (s2) ;write seconds to string
ADD s2, 01
STORE s0, (s2)
ADD s2, 01
LOAD s0, character_CR ;finish string with carriage return
STORE s0, (s2)
RETURN
;
;Convert value provided in register s0 into ASCII characters
;
;The value provided must in the range 0 to 99 and will be converted into
;two ASCII characters.
; The number of 'tens' will be representd by an ASCII character returned in register s1.
; The number of 'units' will be representd by an ASCII character returned in register s0.
;
;The ASCII representations of '0' to '9' are 30 to 39 hexadecimal which is simply 30 hex added to
;the actual decimal value.
;
;Registers used s0 and s1.
;
decimal_to_ASCII: LOAD s1, 30 ;load 'tens' counter with ASCII for '0'
test_for_ten: ADD s1, 01 ;increment 'tens' value
SUB s0, 0A ;try to subtract 10 from the supplied value
JUMP NC, test_for_ten ;repeat if subtraction was possible without underflow.
SUB s1, 01 ;'tens' value one less ten due to underflow
ADD s0, 3A ;restore units value (the remainder) and convert to ASCII
RETURN
;
;
;
;
;Real Time Clock
;
;Uses the 1us interrupt counter [int_counter_msb,int_counter_lsb] to determine how many
;micro-seconds have elapsed since the last update. This allows for just over 65ms between
;updates. Complete multiples of 1000us are used to update a 16-bit milli-second counter held
;in scratch pad memory locations [ms_time_stamp_msb,ms_time_stamp_msb] which in turn
;is used to update the real time hours, minutes and seconds clock held in scratch pad
;memory locations 'real_time_hours', 'real_time_minutes' and 'real_time_seconds'.
;
;The routine uses default register names s0,s1,s2,s3,s4,s5. These are preserved in scratch pad
;memory during the routine and restored before returning.
;
;Useful constants for real time clock operations
;
CONSTANT count_1000_lsb, E8 ;lower 8-bits of 1000 count value
CONSTANT count_1000_msb, 03 ;upper 8-bits of 1000 count value
CONSTANT hours_in_a_day, 18 ;24 hours in a day
CONSTANT minutes_in_an_hour, 3C ;60 minutes in an hour
CONSTANT seconds_in_a_minute, 3C ;60 seconds in a minute
;
update_time: STORE s0, time_preserve0 ;preserve contents of registers used during routine
STORE s1, time_preserve1
STORE s2, time_preserve2
STORE s3, time_preserve3
STORE s4, time_preserve4
STORE s5, time_preserve5
;
FETCH s2, us_time_stamp_lsb ;read the previous 'us' time stamp into [s3,s2]
FETCH s3, us_time_stamp_msb
DISABLE INTERRUPT ;Read and store current 'us' time stamp provided by the interrupt
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -