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

📄 uclock.log

📁 UART transmitter and receiver mocros
💻 LOG
📖 第 1 页 / 共 5 页
字号:
 16E  18201                          ADD s2, 01
 16F  2F020                          STORE s0, (s2)
 170  18201                          ADD s2, 01
 171  0003A                          LOAD s0, character_colon[3A]                     ;write ':' to string
 172  2F020                          STORE s0, (s2)
 173  18201                          ADD s2, 01
 174  18E01                          ADD store_pointer[sE], 01                        ;move to seconds
 175  070E0                          FETCH s0, (store_pointer)[(sE)]                  ;read seconds value
 176  3017E                          CALL decimal_to_ASCII[17E]                       ;convert to ASCII
 177  2F120                          STORE s1, (s2)                                   ;write seconds to string
 178  18201                          ADD s2, 01
 179  2F020                          STORE s0, (s2)
 17A  18201                          ADD s2, 01
 17B  0000D                          LOAD s0, character_CR[0D]                        ;finish string with carriage return
 17C  2F020                          STORE s0, (s2)
 17D  2A000                          RETURN
 17E                                 ;
 17E                                 ;Convert value provided in register s0 into ASCII characters
 17E                                 ;
 17E                                 ;The value provided must in the range 0 to 99 and will be converted into
 17E                                 ;two ASCII characters.
 17E                                 ;     The number of 'tens' will be representd by an ASCII character returned in register s1.
 17E                                 ;     The number of 'units' will be representd by an ASCII character returned in register s0.
 17E                                 ;
 17E                                 ;The ASCII representations of '0' to '9' are 30 to 39 hexadecimal which is simply 30 hex added to
 17E                                 ;the actual decimal value.
 17E                                 ;
 17E                                 ;Registers used s0 and s1.
 17E                                 ;
 17E  00130        decimal_to_ASCII: LOAD s1, 30                                      ;load 'tens' counter with ASCII for '0'
 17F  18101            test_for_ten: ADD s1, 01                                       ;increment 'tens' value
 180  1C00A                          SUB s0, 0A                                       ;try to subtract 10 from the supplied value
 181  35D7F                          JUMP NC, test_for_ten[17F]                       ;repeat if subtraction was possible without underflow.
 182  1C101                          SUB s1, 01                                       ;'tens' value one less ten due to underflow
 183  1803A                          ADD s0, 3A                                       ;restore units value (the remainder) and convert to ASCII
 184  2A000                          RETURN
 185                                 ;
 185                                 ;
 185                                 ;
 185                                 ;
 185                                 ;Real Time Clock
 185                                 ;
 185                                 ;Uses the 1us interrupt counter [int_counter_msb,int_counter_lsb] to determine how many
 185                                 ;micro-seconds have elapsed since the last update. This allows for just over 65ms between
 185                                 ;updates. Complete multiples of 1000us are used to update a 16-bit milli-second counter held
 185                                 ;in scratch pad memory locations [ms_time_stamp_msb,ms_time_stamp_msb] which in turn
 185                                 ;is used to update the real time hours, minutes and seconds clock held in scratch pad
 185                                 ;memory locations 'real_time_hours', 'real_time_minutes' and 'real_time_seconds'.
 185                                 ;
 185                                 ;The routine uses default register names s0,s1,s2,s3,s4,s5. These are preserved in scratch pad
 185                                 ;memory during the routine and restored before returning.
 185                                 ;
 185                                 ;Useful constants for real time clock operations
 185                                 ;
 185                                 CONSTANT count_1000_lsb, E8                      ;lower 8-bits of 1000 count value
 185                                 CONSTANT count_1000_msb, 03                      ;upper 8-bits of 1000 count value
 185                                 CONSTANT hours_in_a_day, 18                      ;24 hours in a day
 185                                 CONSTANT minutes_in_an_hour, 3C                  ;60 minutes in an hour
 185                                 CONSTANT seconds_in_a_minute, 3C                 ;60 seconds in a minute
 185                                 ;
 185  2E010             update_time: STORE s0, time_preserve0[10]                     ;preserve contents of registers used during routine
 186  2E111                          STORE s1, time_preserve1[11]
 187  2E212                          STORE s2, time_preserve2[12]
 188  2E313                          STORE s3, time_preserve3[13]
 189  2E414                          STORE s4, time_preserve4[14]
 18A  2E515                          STORE s5, time_preserve5[15]
 18B                                 ;
 18B  06200                          FETCH s2, us_time_stamp_lsb[00]                  ;read the previous 'us' time stamp into [s3,s2]
 18C  06301                          FETCH s3, us_time_stamp_msb[01]
 18D  3C000                          DISABLE INTERRUPT                                ;Read and store current 'us' time stamp provided by the interrupt
 18E  2ED00                          STORE int_counter_lsb[sD], us_time_stamp_lsb[00] ;counter. Interrupts are disabled to ensure that both bytes relate
 18F  2EC01                          STORE int_counter_msb[sC], us_time_stamp_msb[01] ;to the same count value.
 190  3C001                          ENABLE INTERRUPT
 191  06400                          FETCH s4, us_time_stamp_lsb[00]                  ;read the new 'us' time stamp in [s5,s4]
 192  06501                          FETCH s5, us_time_stamp_msb[01]                  ;
 193  1D420                          SUB s4, s2                                       ;calculate 'us' time difference [s5,s4] = [s5,s4] - [s3,s2]
 194  1F530                          SUBCY s5, s3                                     ;   (This works correctly even if counter has rolled over)
 195  06202                          FETCH s2, us_time_lsb[02]                        ;read current 'us' time into [s3,s2]
 196  06303                          FETCH s3, us_time_msb[03]
 197  19240                          ADD s2, s4                                       ;add on the elapsed 'us' value [s3,s2] = [s3,s2] + [s5,s4]
 198  1B350                          ADDCY s3, s5
 199                                 ;determine how many 1000us (1ms) units there are (if any) in current 'us' time
 199  00000                          LOAD s0, 00                                      ;reset 'ms' counter
 19A  1C2E8             test_1000us: SUB s2, count_1000_lsb[E8]                       ;subtract 1000 from [s3,s2]
 19B  1E303                          SUBCY s3, count_1000_msb[03]
 19C  3599F                          JUMP C, store_us_time[19F]                       ;Carry indicates [s3,s2] was less than 1000us
 19D  18001                          ADD s0, 01                                       ;increment 'ms' elapsed because [s3,s2] was more or equal to 1000us
 19E  3419A                          JUMP test_1000us[19A]                            ;repeat to see if more than 1ms has elapsed
 19F  182E8           store_us_time: ADD s2, count_1000_lsb[E8]                       ;add 1000 to restore 'us' value
 1A0  1A303                          ADDCY s3, count_1000_msb[03]
 1A1  2E202                          STORE s2, us_time_lsb[02]                        ;store the current value of 'us'
 1A2  2E303                          STORE s3, us_time_msb[03]
 1A3                                 ;s0 holds the number of 'ms' elapsed since last update (if any).
 1A3  06204                          FETCH s2, ms_time_lsb[04]                        ;read current 'ms' time into [s3,s2]
 1A4  06305                          FETCH s3, ms_time_msb[05]
 1A5  19200                          ADD s2, s0                                       ;add on the elapsed 'ms' value [s3,s2] = [s3,s2] + s0
 1A6  1A300                          ADDCY s3, 00
 1A7                                 ;determine if there are now more than 1000ms to form 1 second.
 1A7  00000                          LOAD s0, 00                                      ;reset 'second' counter
 1A8  1C2E8                          SUB s2, count_1000_lsb[E8]                       ;subtract 1000 from [s3,s2]
 1A9  1E303                          SUBCY s3, count_1000_msb[03]
 1AA  359AD                          JUMP C, restore_ms_time[1AD]                     ;Carry indicates [s3,s2] was less than 1000ms
 1AB  18001                          ADD s0, 01                                       ;increment 'second' elapsed because [s3,s2] was more or equal to 1000ms
 1AC  341AF                          JUMP store_ms_time[1AF]                          ;new value of 'ms' is remainder of subtraction
 1AD  182E8         restore_ms_time: ADD s2, count_1000_lsb[E8]                       ;add 1000 to restore 'ms' value
 1AE  1A303                          ADDCY s3, count_1000_msb[03]
 1AF  2E204           store_ms_time: STORE s2, ms_time_lsb[04]                        ;store the current value of 'ms'
 1B0  2E305                          STORE s3, ms_time_msb[05]
 1B1                                 ;s0 currently determines if one second needs to be added to the hh:mm:ss clock time
 1B1  06108                          FETCH s1, real_time_seconds[08]                  ;read seconds
 1B2  19100                          ADD s1, s0                                       ;add one second if required by s0
 1B3  1413C                          COMPARE s1, seconds_in_a_minute[3C]              ;test for 1 minute
 1B4  351B7                          JUMP Z, inc_minutes[1B7]
 1B5  2E108                          STORE s1, real_time_seconds[08]                  ;store updated seconds
 1B6  341C9                          JUMP time_update_complete[1C9]
 1B7  00100             inc_minutes: LOAD s1, 00                                      ;seconds become zero
 1B8  2E108                          STORE s1, real_time_seconds[08]
 1B9  06107                          FETCH s1, real_time_minutes[07]                  ;read minutes
 1BA  18101                          ADD s1, 01                                       ;increment minutes
 1BB  1413C                          COMPARE s1, minutes_in_an_hour[3C]               ;test for 1 hour
 1BC  351BF                          JUMP Z, inc_hours[1BF]
 1BD  2E107                          STORE s1, real_time_minutes[07]                  ;store updated minutes
 1BE  341C9                          JUMP time_update_complete[1C9]
 1BF  00100               inc_hours: LOAD s1, 00                                      ;minutes become zero
 1C0  2E107                          STORE s1, real_time_minutes[07]
 1C1  06106                          FETCH s1, real_time_hours[06]                    ;read hours
 1C2  18101                          ADD s1, 01                                       ;increment hours
 1C3  14118                          COMPARE s1, hours_in_a_day[18]                   ;test for 24 hours
 1C4  351C7                          JUMP Z, reset_hours[1C7]
 1C5  2E106                          STORE s1, real_time_hours[06]                    ;store updated hours
 1C6  341C9                          JUMP time_update_complete[1C9]
 1C7  00100             reset_hours: LOAD s1, 00                                      ;hours become zero
 1C8  2E106                          STORE s1, real_time_hours[06]
 1C9                                 ;
 1C9                                 ;With the time updated, there is then a test for time=alarm time
 1C9                                 ;
 1C9  06006    time_update_complete: FETCH s0, real_time_hours[06]
 1CA  06109                          FETCH s1, alarm_time_hours[09]                   ;compare hours
 1CB  15010                          COMPARE s0, s1
 1CC  355DB                          JUMP NZ, finish_update[1DB]
 1CD  06007                          FETCH s0, real_time_minutes[07]                  ;compare minutes
 1CE  0610A                          FETCH s1, alarm_time_minutes[0A]
 1CF  15010                          COMPARE s0, s1
 1D0  355DB                          JUMP NZ, finish_update[1DB]
 1D1  06008                          FETCH s0, real_time_seconds[08]                  ;compare seconds
 1D2  0610B                          FETCH s1, alarm_time_seconds[0B]
 1D3  15010                          COMPARE s0, s1
 1D4  355DB                          JUMP NZ, finish_update[1DB]
 1D5  0600C                          FETCH s0, alarm_status[0C]                       ;test if alarm is turned on
 1D6  12002                          TEST s0, alarm_armed[02]
 1D7  351DB                          JUMP Z, finish_update[1DB]                       ;alarm was off
 1D8  0C001                          OR s0, alarm_active[01]                          ;activate alarm
 1D9  2E00C                          STORE s0, alarm_status[0C]
 1DA  300A4                          CALL alarm_drive[0A4]
 1DB  06010           finish_update: FETCH s0, time_preserve0[10]                     ;restore the register contents
 1DC  06111                          FETCH s1, time_preserve1[11]
 1DD  06212                          FETCH s2, time_preserve2[12]
 1DE  06313                          FETCH s3, time_preserve3[13]
 1DF  06414                          FETCH s4, time_preserve4[14]
 1E0  06515                          FETCH s5, time_preserve5[15]
 1E1  2A000                          RETURN
 1E2                                 ;
 1E2                                 ;Convert character to upper case
 1E2                                 ;
 1E2                                 ;The character supplied in register s0.
 1E2                                 ;If the character is in the range 'a' to 'z', it is converted
 1E2                                 ;to the equivalent upper case character in the range 'A' to 'Z'.
 1E2                                 ;All other characters remain unchanged.
 1E2                                 ;
 1E2                                 ;Registers used s0.
 1E2                                 ;
 1E2  14061              upper_case: COMPARE s0, 61                                   ;eliminate character codes below 'a' (61 hex)
 1E3  2B800                          RETURN C
 1E4  1407B                   

⌨️ 快捷键说明

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