📄 usbjoy32.lst
字号:
01A2 08 42 [06] sub a, [capture_a_temp]
01A4 31 60 [05] mov [y_R1_diff1_new], a
01A6 1A 40 [05] mov a, [rollover_bit]
01A8 0B 00 [06] sbb a, [00h]
01AA 31 44 [05] mov [always_zero], a
***END MACRO***
01AC 19 05 [04] mov a, 05h ;Re-Enable 1ms,USBReset interrupts
01AE 2A 20 [05] iowr Global_Interrupt
01B0 80 79 [05] jmp TaskLoop
;===========================================================
;
; Task 4: Read Resistor Value for y_R2
;============================================================
01B2 Task4:
01B2 19 30 [04] mov a, 30h
01B4 2A 20 [05] iowr Global_Interrupt ;Enable only Capture interrupts
;**********************************************
;P0.0 = CMOS Hi-Z
;P0.1 = TTL Hi-Z
;P0.5 = High Sink
;P0.2/P0.3/P0.4/P0.6/P0.7 = CMOS Hi-Z
;Port0_Mode0 = 00100000
;Port0_Mode1 = 00100000
;Port0 = 00000010
;**********************************************
01B6 19 20 [04] mov a, 20h ;Set port and port mode values to discharge capacitor
01B8 2A 0A [05] iowr Port0_Mode0 ;See table above
01BA 2A 0B [05] iowr Port0_Mode1
01BC 19 02 [04] mov a, 02h
01BE 2A 00 [05] iowr Port0
01C0 19 00 [04] mov a, 00h ;wait about 500usec (6000 cycles) for Capture_timer A & B ISRs, then recharge cap and do math below
01C2 31 41 [05] mov [discharge_cnt], a
01C4 .discharge_loop:
01C4 23 41 [07] inc [discharge_cnt]
01C6 19 CC [04] mov a, CCh
01C8 17 41 [07] cmp a, [discharge_cnt]
01CA 2A 26 [05] iowr Watchdog
01CC B1 C4 [05] jnz .discharge_loop
01CE 19 00 [04] mov a, 00h
01D0 2A 20 [05] iowr Global_Interrupt ;Disable global interrupts
01D2 19 00 [04] mov a, 00h
01D4 31 40 [05] mov [rollover_bit], a ;rollover_bit set to 00h, but may need to change to 01h, if TTL value is < CMOS value
01D6 29 41 [05] iord Capture_TimerA_Falling ;Read CaptureTimerA 8 bits, CMOS captured time value (always earlier and usually the smaller value)
01D8 31 42 [05] mov [capture_a_temp], a
01DA 29 43 [05] iord Capture_TimerB_Falling ;Read CaptureTimerB 8 bits, TTL captured time value (always earlier and usually the larger value)
01DC 31 43 [05] mov [capture_b_temp], a
01DE 08 42 [06] sub a, [capture_a_temp] ;Subtract CMOS time from TTL time to see if timer rolled over
01E0 D1 E6 [05] jnc .no_timer_rollover ;If TTL value is > CMOS value, the timer did not roll over and we keep rollover_bit = 00h
01E2 19 01 [04] mov a, 01h ;In the exception that TTL time value is < CMOS time value, we make rollover_bit = 01h
01E4 31 40 [05] mov [rollover_bit], a
01E6 .no_timer_rollover:
01E6 19 FE [04] mov a, FEh ;Recharges the capacitor, P0.0 is Hi-Z CMOS always, others set to Strong Drive CMOS
01E8 2A 0A [05] iowr Port0_Mode0
01EA 2A 0B [05] iowr Port0_Mode1
01EC 2A 00 [05] iowr Port0
**** MACRO **** SUB16x16 rollover_bit, capture_b_temp, 00h, capture_a_temp, always_zero, y_R2_diff1_new
01EE 1A 43 [05] mov a, [capture_b_temp]
01F0 08 42 [06] sub a, [capture_a_temp]
01F2 31 64 [05] mov [y_R2_diff1_new], a
01F4 1A 40 [05] mov a, [rollover_bit]
01F6 0B 00 [06] sbb a, [00h]
01F8 31 44 [05] mov [always_zero], a
***END MACRO***
01FA 19 05 [04] mov a, 05h ;Re-Enable 1ms,USBReset interrupts
01FC 2A 20 [05] iowr Global_Interrupt
01FE 20 [04] NOP
01FF 1F [04] XPAGE
0200 80 79 [05] jmp TaskLoop
;========================================
; Task 5: Read Resistor Value for z_R1
;========================================
0202 Task5:
0202 19 30 [04] mov a, 30h
0204 2A 20 [05] iowr Global_Interrupt ;Enable only Capture interrupts
;**********************************************
;P0.0 = CMOS Hi-Z
;P0.1 = TTL Hi-Z
;P0.6 = High Sink
;P0.2/P0.3/P0.4/P0.5/P0.7 = CMOS Hi-Z
;Port0_Mode0 = 01000000
;Port0_Mode1 = 01000000
;Port0 = 00000010
;**********************************************
0206 19 40 [04] mov a, 40h ;Set port and port mode values to discharge capacitor
0208 2A 0A [05] iowr Port0_Mode0 ;See table above
020A 2A 0B [05] iowr Port0_Mode1
020C 19 02 [04] mov a, 02h
020E 2A 00 [05] iowr Port0
0210 19 00 [04] mov a, 00h ;wait about 500usec (6000 cycles) for Capture_timer A & B ISRs, then recharge cap and do math below
0212 31 41 [05] mov [discharge_cnt], a
0214 .discharge_loop:
0214 23 41 [07] inc [discharge_cnt]
0216 19 CC [04] mov a, CCh
0218 17 41 [07] cmp a, [discharge_cnt]
021A 2A 26 [05] iowr Watchdog
021C B2 14 [05] jnz .discharge_loop
021E 19 00 [04] mov a, 00h
0220 2A 20 [05] iowr Global_Interrupt ;Disable global interrupts
0222 19 00 [04] mov a, 00h
0224 31 40 [05] mov [rollover_bit], a ;rollover_bit set to 00h, but may need to change to 01h, if TTL value is < CMOS value
0226 29 41 [05] iord Capture_TimerA_Falling ;Read CaptureTimerA 8 bits, CMOS captured time value (always earlier and usually the smaller value)
0228 31 42 [05] mov [capture_a_temp], a
022A 29 43 [05] iord Capture_TimerB_Falling ;Read CaptureTimerB 8 bits, TTL captured time value (always earlier and usually the larger value)
022C 31 43 [05] mov [capture_b_temp], a
022E 08 42 [06] sub a, [capture_a_temp] ;Subtract CMOS time from TTL time to see if timer rolled over
0230 D2 36 [05] jnc .no_timer_rollover ;If TTL value is > CMOS value, the timer did not roll over and we keep rollover_bit = 00h
0232 19 01 [04] mov a, 01h ;In the exception that TTL time value is < CMOS time value, we make rollover_bit = 01h
0234 31 40 [05] mov [rollover_bit], a
0236 .no_timer_rollover:
0236 19 FE [04] mov a, FEh ;Recharges the capacitor, P0.0 is Hi-Z CMOS always, others set to Strong Drive CMOS
0238 2A 0A [05] iowr Port0_Mode0
023A 2A 0B [05] iowr Port0_Mode1
023C 2A 00 [05] iowr Port0
**** MACRO **** SUB16x16 rollover_bit, capture_b_temp, 00h, capture_a_temp, always_zero, z_R1_diff1_new
023E 1A 43 [05] mov a, [capture_b_temp]
0240 08 42 [06] sub a, [capture_a_temp]
0242 31 70 [05] mov [z_R1_diff1_new], a
0244 1A 40 [05] mov a, [rollover_bit]
0246 0B 00 [06] sbb a, [00h]
0248 31 44 [05] mov [always_zero], a
***END MACRO***
024A 19 05 [04] mov a, 05h ;Re-Enable 1ms,USBReset interrupts
024C 2A 20 [05] iowr Global_Interrupt
024E 80 79 [05] jmp TaskLoop
;========================================
; Task 6: Read Resistor Value for z_R2
;========================================
0250 Task6:
0250 19 30 [04] mov a, 30h
0252 2A 20 [05] iowr Global_Interrupt ;Enable only Capture interrupts
;**********************************************
;P0.0 = CMOS Hi-Z
;P0.1 = TTL Hi-Z
;P0.5 = High Sink
;P0.2/P0.3/P0.4/P0.6/P0.7 = CMOS Hi-Z
;Port0_Mode0 = 10000000
;Port0_Mode1 = 10000000
;Port0 = 00000010
;**********************************************
0254 19 80 [04] mov a, 80h ;Set port and port mode values to discharge capacitor
0256 2A 0A [05] iowr Port0_Mode0 ;See table above
0258 2A 0B [05] iowr Port0_Mode1
025A 19 02 [04] mov a, 02h
025C 2A 00 [05] iowr Port0
025E 19 00 [04] mov a, 00h ;wait about 500usec (6000 cycles) for Capture_timer A & B ISRs, then recharge cap and do math below
0260 31 41 [05] mov [discharge_cnt], a
0262 .discharge_loop:
0262 23 41 [07] inc [discharge_cnt]
0264 19 CC [04] mov a, CCh
0266 17 41 [07] cmp a, [discharge_cnt]
0268 2A 26 [05] iowr Watchdog
026A B2 62 [05] jnz .discharge_loop
026C 19 00 [04] mov a, 00h
026E 2A 20 [05] iowr Global_Interrupt ;Disable global interrupts
0270 19 00 [04] mov a, 00h
0272 31 40 [05] mov [rollover_bit], a ;rollover_bit set to 00h, but may need to change to 01h, if TTL value is < CMOS value
0274 29 41 [05] iord Capture_TimerA_Falling ;Read CaptureTimerA 8 bits, CMOS captured time value (always earlier and usually the smaller value)
0276 31 42 [05] mov [capture_a_temp], a
0278 29 43 [05] iord Capture_TimerB_Falling ;Read CaptureTimerB 8 bits, TTL captured time value (always earlier and usually the larger value)
027A 31 43 [05] mov [capture_b_temp], a
027C 08 42 [06] sub a, [capture_a_temp] ;Subtract CMOS time from TTL time to see if timer rolled over
027E D2 84 [05] jnc .no_timer_rollover ;If TTL value is > CMOS value, the timer did not roll over and we keep rollover_bit = 00h
0280 19 01 [04] mov a, 01h ;In the exception that TTL time value is < CMOS time value, we make rollover_bit = 01h
0282 31 40 [05] mov [rollover_bit], a
0284 .no_timer_rollover:
0284 19 FE [04] mov a, FEh ;Recharges the capacitor, P0.0 is Hi-Z CMOS always, others set to Strong Drive CMOS
0286 2A 0A [05] iowr Port0_Mode0
0288 2A 0B [05] iowr Port0_Mode1
028A 2A 00 [05] iowr Port0
**** MACRO **** SUB16x16 rollover_bit, capture_b_temp, 00h, capture_a_temp, always_zero, z_R2_diff1_new
028C 1A 43 [05] mov a, [capture_b_temp]
028E 08 42 [06] sub a, [capture_a_temp]
0290 31 74 [05] mov [z_R2_diff1_new], a
0292 1A 40 [05] mov a, [rollover_bit]
0294 0B 00 [06] sbb a, [00h]
0296 31 44 [05] mov [always_zero], a
***END MACRO***
0298 19 05 [04] mov a, 05h ;Re-Enable 1ms,USBReset interrupts
029A 2A 20 [05] iowr Global_Interrupt
029C 80 79 [05] jmp TaskLoop
;==========================================================
; Task 7:
; {
; if (button state has been stable for 5ms)
; save button state
; }
;==========================================================
029E Task7:
029E 29 01 [05] iord Port1
02A0 10 FF [04] and A, ffh
02A2 17 36 [07] cmp A, [button_debounce]
02A4 B0 79 [05] jnz TaskLoop
02A6 13 FF [04] xor A, ffh
02A8 31 3B [05] mov [new_buttons], A
02AA 31 3D [05] mov [hat_buttons], a
02AC 31 3E [05] mov [fire_buttons], a
02AE 19 0F [04] mov
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -