📄 picservo.lst
字号:
00AB 00658 ProcessServos
00659 ; Process each of the servos and send the control pulse if needed.
00660 ; We move the address of the Servo's Control data into the FSR and call
00661 ; the DoServoControlPulse subroutine.
00AB 1126 00662 BCF Flag_ServoPulseSafe
00663
00664 ; Check that Servo 0 is enabled, skip if it isn't
00AC 1C27 00665 BTFSS Flag_Servo0_Active
00AD 28B0 00666 GOTO DoServo1
00AE 3000 00667 MOVLW 0 ; Servo 0
00AF 2054 00668 CALL DoServoControlPulse
00669
00B0 00670 DoServo1
00B0 1CA7 00671 BTFSS Flag_Servo1_Active
00B1 28B4 00672 GOTO DoServo2
00B2 3001 00673 MOVLW 1 ; Servo 1
00B3 2054 00674 CALL DoServoControlPulse
00675
00B4 00676 DoServo2
00B4 1D27 00677 BTFSS Flag_Servo2_Active
00B5 28B8 00678 GOTO DoServo3
00B6 3002 00679 MOVLW 2 ; Servo 2
00B7 2054 00680 CALL DoServoControlPulse
00681
00B8 00682 DoServo3
00B8 1DA7 00683 BTFSS Flag_Servo3_Active
00B9 28BC 00684 GOTO DoServo4
00BA 3003 00685 MOVLW 3 ; Servo 3
00BB 2054 00686 CALL DoServoControlPulse
00687
00BC 00688 DoServo4
00BC 1E27 00689 BTFSS Flag_Servo4_Active
00BD 28C0 00690 GOTO DoServo5
00BE 3004 00691 MOVLW 4 ; Servo 4
00BF 2054 00692 CALL DoServoControlPulse
00693
00C0 00694 DoServo5
00C0 1EA7 00695 BTFSS Flag_Servo5_Active
00C1 28C4 00696 GOTO DoServo6
00C2 3005 00697 MOVLW 5 ; Servo 5
00C3 2054 00698 CALL DoServoControlPulse
00699
00C4 00700 DoServo6
00C4 1F27 00701 BTFSS Flag_Servo6_Active
00C5 28C8 00702 GOTO DoServo7
00C6 3006 00703 MOVLW 6 ; Servo 6
00C7 2054 00704 CALL DoServoControlPulse
00705
00C8 00706 DoServo7
00C8 1FA7 00707 BTFSS Flag_Servo7_Active
00C9 28CC 00708 GOTO DoLED
00CA 3007 00709 MOVLW 7 ; Servo 7
00CB 2054 00710 CALL DoServoControlPulse
MPASM 4.02 Released PICSERVO.ASM 12-31-2006 11:50:00 PAGE 15
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00711
00CC 00712 DoLED
00713 ; If the LED Drive counter is not zero, check if it has timed out so needs disabling
00CC 08A8 00714 MOVF LED_Drive_Count, f
00CD 1903 00715 BTFSC STATUS, Z
00CE 28D2 00716 GOTO ResetTimer
00717
00718 ; Decrement the LED counter and if it hits zero, turn off the LED
00CF 0BA8 00719 DECFSZ LED_Drive_Count, f
00D0 28D2 00720 GOTO ResetTimer ; not zero, contine with next bit
00721
00722 ; Turn off LED
00D1 1605 00723 BSF LED_Drive
00724
00D2 00725 ResetTimer
00726 ; Clear the interrupt flag so we don't interrupt again as soon as we exit
00727 ; and reset the RTCC register to wait for another 19ms
00D2 306B 00728 MOVLW RTCC_19msValue
00D3 0081 00729 MOVWF TMR0
00D4 110B 00730 BCF INTCON, T0IF
00D5 168B 00731 BSF INTCON, T0IE ; unmask the timer interrupt
00732
00733 ; Reenable the CTS flag so the computer can send us more data
00D6 1105 00734 BCF Serial_CTS
00735
00736 ; return to looking for a start bit
00D7 289A 00737 GOTO StartBitLoop
00738
00739 ;+-----------------------------------------------------------------------------
00740 ;| SUBROUTINE: ResetState
00741 ;|
00742 ;| Set all the outputs to the reset state. That is:
00743 ;| 1. All digital output Off
00744 ;| 2. All Servo outputs disabled
00745 ;| 3. All Servo Offsets to 128 (midrange)
00746 ;| 3. All Servo Positions to 128 (midrange)
00747 ;+-----------------------------------------------------------------------------
00D8 00748 ResetState
00749 ; Clear all the servo enables (all servos off)
00D8 01A7 00750 CLRF Enables
00751
00D9 3080 00752 MOVLW 128
00DA 008D 00753 MOVWF Servo0_Offset
00DB 0090 00754 MOVWF Servo1_Offset
00DC 0093 00755 MOVWF Servo2_Offset
00DD 0096 00756 MOVWF Servo3_Offset
00DE 0099 00757 MOVWF Servo4_Offset
00DF 009C 00758 MOVWF Servo5_Offset
00E0 009F 00759 MOVWF Servo6_Offset
00E1 00A2 00760 MOVWF Servo7_Offset
00E2 008E 00761 MOVWF Servo0_Position
00E3 0091 00762 MOVWF Servo1_Position
00E4 0094 00763 MOVWF Servo2_Position
MPASM 4.02 Released PICSERVO.ASM 12-31-2006 11:50:00 PAGE 16
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00E5 0097 00764 MOVWF Servo3_Position
00E6 009A 00765 MOVWF Servo4_Position
00E7 009D 00766 MOVWF Servo5_Position
00E8 00A0 00767 MOVWF Servo6_Position
00E9 00A3 00768 MOVWF Servo7_Position
00769
00770 ; Turn everything off
00EA 0186 00771 CLRF PORTB
00772
00773 ; Transmit the power on welcome message
00EB 2064 00774 CALL DisableInterrupts
00EC 01AA 00775 CLRF DataByte
00ED 00776 ResetMsgLoop
00ED 082A 00777 MOVF DataByte, w
00EE 2027 00778 CALL GetResetMsg
00EF 39FF 00779 ANDLW 0ffh ; check for end of message
00F0 1903 00780 BTFSC STATUS, Z
00F1 28F5 00781 GOTO EndResetLoop ; was 0, exit
00F2 214D 00782 CALL TransmitDataByte
00F3 0AAA 00783 INCF DataByte, f
00F4 28ED 00784 GOTO ResetMsgLoop
00F5 00785 EndResetLoop
00F5 178B 00786 BSF INTCON, GIE
00787
00F6 0008 00788 RETURN
00789
00790
00791 ;+=============================================================================
00792 ;| Command Parsing Routines.
00793 ;|
00794 ;| The following routines form the command parser and state machine to
00795 ;| handle multi-byte commands.
00796 ;+=============================================================================
00797
00798
00799 ;+-----------------------------------------------------------------------------
00800 ;| SUBROUTINE: ParseCommand
00801 ;|
00802 ;| Parse the given byte in W as a command. All incoming data is sent to this
00803 ;| routine to be interrupted. If the command is a single byte command it is
00804 ;| processed immediatly, if not the Parser waits for the next byte to execute
00805 ;| the command.
00806 ;+-----------------------------------------------------------------------------
00F7 00807 ParseCommand
00808 ; Determine if the Parser is waiting for a data byte, it is
00809 ; store the incoming byte in the data field, if not store it
00810 ; in the command field.
00F7 1CA6 00811 BTFSS Parser_WaitForData
00F8 00AD 00812 MOVWF Parser_Command ; Store in command
00F9 18A6 00813 BTFSC Parser_WaitForData
00FA 00AE 00814 MOVWF Parser_Data ; Store in Data
00815
00816 ; Access the Command nibble and store it in the Parser_Temp variable
MPASM 4.02 Released PICSERVO.ASM 12-31-2006 11:50:00 PAGE 17
LOC OBJECT CODE LINE SOURCE TEXT
VALUE
00817 ; so we can access it and determine what the command is
00FB 0E2D 00818 SWAPF Parser_Command, w ; Place the upper nibble from the command
00819 ; into the W register's lower ni
bble
00FC 390F 00820 ANDLW 0Fh ; Mask out what was the channel select
00FD 00AF 00821 MOVWF Parser_Temp ; Store in a Temp Variable.
00822
00823 ; Check for each command against the stored value and if we
00824 ; match one, goto the handler for that command, if we don't match
00825 ; any command we need to discard the command.
00826
00FE 3000 00827 MOVLW 0h ; Check Reset Command
00FF 022F
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -