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

📄 uclock.log

📁 UART transmitter and receiver mocros
💻 LOG
📖 第 1 页 / 共 5 页
字号:
 0A4                                 ;
 0A4  0600C             alarm_drive: FETCH s0, alarm_status[0C]                       ;read status
 0A5  0A001                          AND s0, alarm_active[01]                         ;isolate bit0
 0A6  2C000                          OUTPUT s0, alarm_port[00]
 0A7  2A000                          RETURN
 0A8                                 ;
 0A8                                 ;
 0A8                                 ;
 0A8                                 ;
 0A8                                 ;
 0A8                                 ;Transmit the time to the UART port in the format hh:mm:ss and end
 0A8                                 ;with a carriage return.
 0A8                                 ;
 0A8                                 ;The time to converted must be stored in 3 scratch pad memory locations as
 0A8                                 ;defined below. A register named 'store_pointer' must provide the address of
 0A8                                 ;first location.
 0A8                                 ;
 0A8                                 ;        Address                Data
 0A8                                 ;
 0A8                                 ;     store_pointer      ----> hours
 0A8                                 ;     store_pointer + 1  ----> minutes
 0A8                                 ;     store_pointer + 1  ----> seconds
 0A8                                 ;
 0A8                                 ;The routine first converts the time into an ASCII string stored in scratch
 0A8                                 ;pad memory starting at a location specified by a constant named 'string_start'.
 0A8                                 ;The string will then be transmitted.
 0A8                                 ;
 0A8                                 ;Registers used s0, s1, s2, 'store_pointer' and 'UART_data'.
 0A8                                 ;
 0A8  00E06           transmit_time: LOAD store_pointer[sE], real_time_hours[06]      ;locate current time in memory
 0A9  30160                          CALL time_to_ASCII[160]
 0AA  300BC                          CALL transmit_string[0BC]
 0AB  2A000                          RETURN
 0AC                                 ;
 0AC                                 ;
 0AC                                 ;Transmit the alarm time and status to the UART port in the format hh:mm:ss and
 0AC                                 ;ending with carriage return.
 0AC                                 ;
 0AC                                 ;The alarm time to converted must be stored in 3 scratch pad memory locations as
 0AC                                 ;defined below. A register named 'store_pointer' must provide the address of
 0AC                                 ;first location.
 0AC                                 ;
 0AC                                 ;        Address                Data
 0AC                                 ;
 0AC                                 ;     store_pointer      ----> hours
 0AC                                 ;     store_pointer + 1  ----> minutes
 0AC                                 ;     store_pointer + 1  ----> seconds
 0AC                                 ;
 0AC                                 ;The routine first converts the time into an ASCII string stored in scratch
 0AC                                 ;pad memory starting at a location specified by a constant named 'string_start'.
 0AC                                 ;The string will then be transmitted.
 0AC                                 ;
 0AC                                 ;Registers used s0, s1, s2, 'store_pointer' and 'UART_data'.
 0AC                                 ;
 0AC  00E09     transmit_alarm_time: LOAD store_pointer[sE], alarm_time_hours[09]     ;locate alarm time in memory
 0AD  30160                          CALL time_to_ASCII[160]
 0AE  300BC                          CALL transmit_string[0BC]
 0AF  3013D                          CALL send_Alarm[13D]
 0B0  300E7                          CALL send_space[0E7]
 0B1  0600C                          FETCH s0, alarm_status[0C]                       ;read alarm status
 0B2  12001                          TEST s0, alarm_active[01]                        ;test for active
 0B3  350B6                          JUMP Z, test_armed[0B6]
 0B4  30153                          CALL send_Active[153]
 0B5  2A000                          RETURN
 0B6  12002              test_armed: TEST s0, alarm_armed[02]                         ;test for on
 0B7  350BA                          JUMP Z, alarm_is_off[0BA]
 0B8  3014E                          CALL send_ON[14E]
 0B9  2A000                          RETURN
 0BA  30148            alarm_is_off: CALL send_OFF[148]
 0BB  2A000                          RETURN
 0BC                                 ;
 0BC                                 ;
 0BC                                 ;Transmit ASCII string to UART
 0BC                                 ;
 0BC                                 ;An ASCII string must be provided in scratch pad memory commencing at the
 0BC                                 ;location specified by a constant named 'string_start'. The string must
 0BC                                 ;end with a carriage return (0D).
 0BC                                 ;
 0BC                                 ;Registers used s1 and 'UART_data'.
 0BC                                 ;               s0 is then used in subroutine 'send_to_UART'
 0BC                                 ;
 0BC  00120         transmit_string: LOAD s1, string_start[20]                        ;locate start of string
 0BD  07F10            next_char_tx: FETCH UART_data[sF], (s1)                        ;read character from memory
 0BE  3009D                          CALL send_to_UART[09D]                           ;transmit character
 0BF  14F0D                          COMPARE UART_data[sF], character_CR[0D]          ;test for last character
 0C0  2B000                          RETURN Z
 0C1  18101                          ADD s1, 01                                       ;move to next character
 0C2  340BD                          JUMP next_char_tx[0BD]
 0C3                                 ;
 0C3                                 ;
 0C3                                 ;Receive ASCII string from UART
 0C3                                 ;
 0C3                                 ;An ASCII string will be read from the UART and stored in scratch pad memory
 0C3                                 ;commencing at the location specified by a constant named 'string_start'.
 0C3                                 ;The string will will have a maximum length of 16 characters including a
 0C3                                 ;carriage return (0D) denoting the end of the string.
 0C3                                 ;
 0C3                                 ;As each character is read, it is echoed to the UART transmitter.
 0C3                                 ;Some minor editing is supported using backspace (BS=08) which is used
 0C3                                 ;to adjust what is stored in scratch pad memory and adjust the display
 0C3                                 ;on the terminal screen using characters sent to the UART transmitter.
 0C3                                 ;
 0C3                                 ;A test is made for the receiver FIFO becoming full. A full status is treated as
 0C3                                 ;a potential error situation and will result in a 'Overflow Error' message being
 0C3                                 ;transmitted to the UART, the receiver FIFO being purged of all data and an
 0C3                                 ;empty string being stored (carriage return at first location).
 0C3                                 ;
 0C3                                 ;Registers used s0, s1, s2 and 'UART_data'.
 0C3                                 ;
 0C3  00120          receive_string: LOAD s1, string_start[20]                        ;locate start of string
 0C4  01210                          LOAD s2, s1                                      ;compute 16 character address
 0C5  18210                          ADD s2, 10
 0C6  04000       receive_full_test: INPUT s0, UART_status_port[00]                   ;test Rx_FIFO buffer for full
 0C7  12008                          TEST s0, rx_full[08]
 0C8  354DB                          JUMP NZ, read_error[0DB]
 0C9  30095                          CALL read_from_UART[095]                         ;obtain and echo character
 0CA  2FF10                          STORE UART_data[sF], (s1)                        ;write to memory
 0CB  14F0D                          COMPARE UART_data[sF], character_CR[0D]          ;test for end of string
 0CC  2B000                          RETURN Z
 0CD  14F08                          COMPARE UART_data[sF], character_BS[08]          ;test for back space
 0CE  350D3                          JUMP Z, BS_edit[0D3]
 0CF  18101                          ADD s1, 01                                       ;increment memory pointer
 0D0  15120                          COMPARE s1, s2                                   ;test for pointer exceeding 16 characters
 0D1  354C6                          JUMP NZ, receive_full_test[0C6]                  ;next character
 0D2  300EA                          CALL send_backspace[0EA]                         ;hold end of string position on terminal display
 0D3  1C101                 BS_edit: SUB s1, 01                                       ;memory pointer back one
 0D4  14120                          COMPARE s1, string_start[20]                     ;test for under flow
 0D5  358D9                          JUMP C, string_start_again[0D9]
 0D6  300E7                          CALL send_space[0E7]                             ;clear character at current position
 0D7  300EA                          CALL send_backspace[0EA]                         ;position cursor
 0D8  340C6                          JUMP receive_full_test[0C6]                      ;next character
 0D9  30122      string_start_again: CALL send_greater_than[122]                      ;restore '>' at prompt
 0DA  340C3                          JUMP receive_string[0C3]                         ;begin again
 0DB                                 ;Receiver buffer overflow condition
 0DB  300E4              read_error: CALL send_CR[0E4]                                ;Transmit error message
 0DC  2EF20                          STORE UART_data[sF], string_start[20]            ;empty string in memory (start with CR)
 0DD  300FA                          CALL send_Overflow_Error[0FA]
 0DE  300E4                          CALL send_CR[0E4]
 0DF  04000      clear_UART_Rx_loop: INPUT s0, UART_status_port[00]                   ;test Rx_FIFO buffer for data
 0E0  12010                          TEST s0, rx_data_present[10]
 0E1  2B000                          RETURN Z                                         ;finish when buffer is empty
 0E2  04F01                          INPUT UART_data[sF], UART_read_port[01]          ;read from FIFO and ignore
 0E3  340DF                          JUMP clear_UART_Rx_loop[0DF]
 0E4                                 ;
 0E4                                 ;
 0E4                                 ;
 0E4                                 ;Send Carriage Return to the UART
 0E4                                 ;
 0E4  00F0D                 send_CR: LOAD UART_data[sF], character_CR[0D]
 0E5  3009D                          CALL send_to_UART[09D]
 0E6  2A000                          RETURN
 0E7                                 ;
 0E7                                 ;
 0E7                                 ;
 0E7                                 ;Send a space to the UART
 0E7                                 ;
 0E7  00F20              send_space: LOAD UART_data[sF], character_space[20]
 0E8  3009D                          CALL send_to_UART[09D]
 0E9  2A000                          RETURN
 0EA                                 ;
 0EA                                 ;
 0EA                                 ;Send a back space to the UART
 0EA                                 ;
 0EA  00F08          send_backspace: LOAD UART_data[sF], character_BS[08]
 0EB  3009D                          CALL send_to_UART[09D]
 0EC  2A000                          RETURN
 0ED                                 ;
 0ED                                 ;Send 'Syntax Error' to the UART
 0ED                                 ;
 0ED  00F53       send_Syntax_Error: LOAD UART_data[sF], character_S[53]
 0EE  3009D                          CALL send_to_UART[09D]
 0EF  00F79                          LOAD UART_data[sF], character_y[79]
 0F0  3009D                          CALL send_to_UART[09D]
 0F1  00F6E                          LOAD UART_data[sF], character_n[6E]

⌨️ 快捷键说明

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