📄 map_bot.lst
字号:
0653 ;
0654 ;
0655 ; // check for timer zero interrupt
0656 ; if (T0IF)
00E6 1D0B 0657 m013 BTFSS 0x0B,T0IF
00E7 2937 0658 GOTO m021
0659 ; {
0660 ;
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 12
ADDR CODE LINE SOURCE
0661 ; if (servo_mode == 0) // setupup for base pos wait
00E8 1283 0662 BCF 0x03,RP0
00E9 1303 0663 BCF 0x03,RP1
00EA 08DE 0664 MOVF servo_mode,1
00EB 1D03 0665 BTFSS 0x03,Zero_
00EC 2906 0666 GOTO m016
0667 ; {
0668 ; servo_mode = 1; // next trigger we will setup for base delay
00ED 3001 0669 MOVLW .1
00EE 00DE 0670 MOVWF servo_mode
0671 ; OPTION = 4; // reset back into 1:32 prescaled mode
00EF 3004 0672 MOVLW .4
00F0 1683 0673 BSF 0x03,RP0
00F1 0081 0674 MOVWF OPTION_REG
0675 ;
0676 ; TMR0 = 0xa0; // set base time delay
00F2 30A0 0677 MOVLW .160
00F3 1283 0678 BCF 0x03,RP0
00F4 0081 0679 MOVWF TMR0
0680 ;
0681 ; unsigned char s = 1 << cur_servo; // create mask
00F5 3001 0682 MOVLW .1
00F6 00A1 0683 MOVWF s
00F7 085F 0684 MOVF cur_servo,W
00F8 1903 0685 BTFSC 0x03,Zero_
00F9 2901 0686 GOTO m015
00FA 00A2 0687 MOVWF C1cnt
00FB 1003 0688 m014 BCF 0x03,Carry
00FC 1283 0689 BCF 0x03,RP0
00FD 1303 0690 BCF 0x03,RP1
00FE 0DA1 0691 RLF s,1
00FF 0BA2 0692 DECFSZ C1cnt,1
0100 28FB 0693 GOTO m014
0694 ;
0695 ; PORTC |= s; // turn this one on
0101 1283 0696 m015 BCF 0x03,RP0
0102 1303 0697 BCF 0x03,RP1
0103 0821 0698 MOVF s,W
0104 0487 0699 IORWF PORTC,1
0700 ;
0701 ; } else
0105 2936 0702 GOTO m020
0703 ; if (servo_mode == 1) // setup for position hold
0106 1283 0704 m016 BCF 0x03,RP0
0107 1303 0705 BCF 0x03,RP1
0108 0B5E 0706 DECFSZ servo_mode,W
0109 2913 0707 GOTO m017
0708 ; {
0709 ; servo_mode = 2; // next mode will turn off and check for long delay
010A 3002 0710 MOVLW .2
010B 00DE 0711 MOVWF servo_mode
0712 ; TMR0 = servo_pos[cur_servo]; // reset the timer to the pos
010C 3043 0713 MOVLW .67
010D 075F 0714 ADDWF cur_servo,W
010E 0084 0715 MOVWF FSR
010F 1383 0716 BCF 0x03,IRP
0110 0800 0717 MOVF INDF,W
0111 0081 0718 MOVWF TMR0
0719 ;
0720 ; } else
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 13
ADDR CODE LINE SOURCE
0112 2936 0721 GOTO m020
0722 ; if (servo_mode == 2) // setupfor next servo
0113 1283 0723 m017 BCF 0x03,RP0
0114 1303 0724 BCF 0x03,RP1
0115 085E 0725 MOVF servo_mode,W
0116 3A02 0726 XORLW .2
0117 1D03 0727 BTFSS 0x03,Zero_
0118 2936 0728 GOTO m020
0729 ; {
0730 ; servo_mode = 0; // reset back to base mode
0119 01DE 0731 CLRF servo_mode
0732 ;
0733 ; unsigned char s = 1 << cur_servo; // create mask
011A 3001 0734 MOVLW .1
011B 00A1 0735 MOVWF s_2
011C 085F 0736 MOVF cur_servo,W
011D 1903 0737 BTFSC 0x03,Zero_
011E 2926 0738 GOTO m019
011F 00A2 0739 MOVWF C2cnt
0120 1003 0740 m018 BCF 0x03,Carry
0121 1283 0741 BCF 0x03,RP0
0122 1303 0742 BCF 0x03,RP1
0123 0DA1 0743 RLF s_2,1
0124 0BA2 0744 DECFSZ C2cnt,1
0125 2920 0745 GOTO m018
0746 ;
0747 ; PORTC &= ~s; // turn the current servo off
0126 1283 0748 m019 BCF 0x03,RP0
0127 1303 0749 BCF 0x03,RP1
0128 0921 0750 COMF s_2,W
0129 0587 0751 ANDWF PORTC,1
0752 ;
0753 ; cur_servo++; // next servo
012A 0ADF 0754 INCF cur_servo,1
0755 ;
0756 ; // Setup longer delay to fill the 20 ms window,
0757 ; // we need to burn 11ms on average
0758 ; // 5Mhz clock, 0.0512 MS per increment at 1:256 prescaler
0759 ; // 11ms / 0.0512 ms = 215 cycles to burn, start time at 40
0760 ;
0761 ; if (cur_servo == NUM_SERVOS)
012B 085F 0762 MOVF cur_servo,W
012C 3A06 0763 XORLW .6
012D 1D03 0764 BTFSS 0x03,Zero_
012E 2936 0765 GOTO m020
0766 ; {
0767 ; cur_servo = 0; // reset back the first servo
012F 01DF 0768 CLRF cur_servo
0769 ;
0770 ; OPTION = 7;
0130 3007 0771 MOVLW .7
0131 1683 0772 BSF 0x03,RP0
0132 0081 0773 MOVWF OPTION_REG
0774 ;
0775 ; TMR0 = 40; // set the value for the longer delay
0133 3028 0776 MOVLW .40
0134 1283 0777 BCF 0x03,RP0
0135 0081 0778 MOVWF TMR0
0779 ; }
0780 ; }
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 14
ADDR CODE LINE SOURCE
0781 ;
0782 ; T0IF = 0; // clear timer zero interrupt
0136 110B 0783 m020 BCF 0x0B,T0IF
0784 ; }
0785 ;
0786 ; // check for timer one interrupt
0787 ; if (TMR1IF)
0137 1283 0788 m021 BCF 0x03,RP0
0138 1303 0789 BCF 0x03,RP1
0139 1C0C 0790 BTFSS 0x0C,TMR1IF
013A 296C 0791 GOTO m026
0792 ; {
0793 ; TMR1L = 0x00; // reset timer
013B 018E 0794 CLRF TMR1L
0795 ; TMR1H = 0x80;
013C 3080 0796 MOVLW .128
013D 008F 0797 MOVWF TMR1H
0798 ;
0799 ; running_counter++;
013E 0AE7 0800 INCF running_counter,1
0801 ;
0802 ;
0803 ;
0804 ;
0805 ;
0806 ; if (running_counter >= 20)
013F 3014 0807 MOVLW .20
0140 0267 0808 SUBWF running_counter,W
0141 1C03 0809 BTFSS 0x03,Carry
0142 294A 0810 GOTO m022
0811 ; {
0812 ;run_count++;
0143 0AEF 0813 INCF run_count,1
0814 ; encoder_0_speed = encoder_0_count;
0144 086A 0815 MOVF encoder_0_count,W
0145 00EE 0816 MOVWF encoder_0_speed
0817 ; encoder_0_count = 0;
0146 01EA 0818 CLRF encoder_0_count
0819 ; led_1 = !led_1;
0147 3080 0820 MOVLW .128
0148 0686 0821 XORWF PORTB,1
0822 ; running_counter = 0;
0149 01E7 0823 CLRF running_counter
0824 ; // led_0 = !led_0;
0825 ; }
0826 ;
0827 ; if (reading_data)
014A 1283 0828 m022 BCF 0x03,RP0
014B 1303 0829 BCF 0x03,RP1
014C 1C64 0830 BTFSS 0x64,reading_data
014D 2956 0831 GOTO m023
0832 ; {
0833 ; read_timeout++;
014E 0AE3 0834 INCF read_timeout,1
0835 ;
0836 ; // The read has timed out
0837 ; if (read_timeout >= 4)
014F 3004 0838 MOVLW .4
0150 0263 0839 SUBWF read_timeout,W
0151 1C03 0840 BTFSS 0x03,Carry
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 15
ADDR CODE LINE SOURCE
0152 2956 0841 GOTO m023
0842 ; {
0843 ; reading_data = 0; // reset reading
0153 1064 0844 BCF 0x64,reading_data
0845 ; cur_recv_byte = 0; // reset to current byte
0154 01E1 0846 CLRF cur_recv_byte
0847 ; last_valid = 1;
0155 14E4 0848 BSF 0x64,last_valid
0849 ; }
0850 ; }
0851 ;
0852 ;
0853 ; // Update time out
0854 ; update_timeout++;
0156 1283 0855 m023 BCF 0x03,RP0
0157 1303 0856 BCF 0x03,RP1
0158 0AE6 0857 INCF update_timeout,1
0858 ;
0859 ; // Too many timeouts have passed, kill motors
0860 ; if (update_timeout >= 30)
0159 301E 0861 MOVLW .30
015A 0266 0862 SUBWF update_timeout,W
015B 1C03 0863 BTFSS 0x03,Carry
015C 2963 0864 GOTO m024
0865 ; {
0866 ; update_timeout = 30;
015D 301E 0867 MOVLW .30
015E 00E6 0868 MOVWF update_timeout
0869 ; pwm_value[0] = 0;
015F 01C9 0870 CLRF pwm_value
0871 ; pwm_value[1] = 0;
0160 01CA 0872 CLRF pwm_value+1
0873 ; pwm_value[2] = 0;
0161 01CB 0874 CLRF pwm_value+2
0875 ; pwm_value[3] = 0;
0162 01CC 0876 CLRF pwm_value+3
0877 ; }
0878 ;
0879 ;
0880 ; // Check for recevive error
0881 ; if (OERR)
0163 1283 0882 m024 BCF 0x03,RP0
0164 1303 0883 BCF 0x03,RP1
0165 1C98 0884 BTFSS 0x18,OERR
0166 2969 0885 GOTO m025
0886 ; {
0887 ; CREN = 0; // reset recieve logic
0167 1218 0888 BCF 0x18,CREN
0889 ; CREN = 1;
0168 1618 0890 BSF 0x18,CREN
0891 ; }
0892 ;
0893 ;
0894 ;
0895 ; TMR1IF = 0; // clear flag
0169 1283 0896 m025 BCF 0x03,RP0
016A 1303 0897 BCF 0x03,RP1
016B 100C 0898 BCF 0x0C,TMR1IF
0899 ; }
0900 ;
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 16
ADDR CODE LINE SOURCE
0901 ; if (TMR2IF)
016C 1283 0902 m026 BCF 0x03,RP0
016D 1303 0903 BCF 0x03,RP1
016E 1C8C 0904 BTFSS 0x0C,TMR2IF
016F 2A04 0905 GOTO m044
0906 ; {
0907 ;// led_0 = encoder_0;
0908 ;
0909 ; if (encoder_0 != last_encoder_0)
0170 1808 0910 BTFSC 0x08,encoder_0
0171 2975 0911 GOTO m027
0172 1964 0912 BTFSC 0x64,last_encoder_0
0173 2979 0913 GOTO m028
0174 2982 0914 GOTO m029
0175 1283 0915 m027 BCF 0x03,RP0
0176 1303 0916 BCF 0x03,RP1
0177 1964 0917 BTFSC 0x64,last_encoder_0
0178 2982 0918 GOTO m029
0919 ; {
0920 ; encoder_low[0]++;
0179 0AF1 0921 m028 INCF encoder_low,1
0922 ;
0923 ; if (encoder_low[0] == 0)
017A 1903 0924 BTFSC 0x03,Zero_
0925 ; encoder_high[0]++;
017B 0AF5 0926 INCF encoder_high,1
0927 ;
0928 ;
0929 ; last_encoder_0 = encoder_0;
017C 1283 0930 BCF 0x03,RP0
017D 1303 0931 BCF 0x03,RP1
017E 1164 0932 BCF 0x64,last_encoder_0
017F 1808 0933 BTFSC 0x08,encoder_0
0180 1564 0934 BSF 0x64,last_encoder_0
0935 ; encoder_0_count++;
0181 0AEA 0936 INCF encoder_0_count,1
0937 ; }
0938 ;
0939 ; if (encoder_1 != last_encoder_1)
0182 1283 0940 m029 BCF 0x03,RP0
0183 1303 0941 BCF 0x03,RP1
0184 1888 0942 BTFSC 0x08,encoder_1
0185 2989 0943 GOTO m030
0186 19E4 0944 BTFSC 0x64,last_encoder_1
0187 298D 0945 GOTO m031
0188 2996 0946 GOTO m032
0189 1283 0947 m030 BCF 0x03,RP0
018A 1303 0948 BCF 0x03,RP1
018B 19E4 0949 BTFSC 0x64,last_encoder_1
018C 2996 0950 GOTO m032
0951 ; {
0952 ; encoder_low[1]++;
018D 0AF2 0953 m031 INCF encoder_low+1,1
0954 ;
0955 ; if (encoder_low[1] == 0)
018E 1903 0956 BTFSC 0x03,Zero_
0957 ; encoder_high[1]++;
018F 0AF6 0958 INCF encoder_high+1,1
0959 ;
0960 ; last_encoder_1 = encoder_1;
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 17
ADDR CODE LINE SOURCE
0190 1283 0961 BCF 0x03,RP0
0191 1303 0962 BCF 0x03,RP1
0192 11E4 0963 BCF 0x64,last_encoder_1
0193 1888 0964 BTFSC 0x08,encoder_1
0194 15E4 0965 BSF 0x64,last_encoder_1
0966 ; encoder_1_count++;
0195 0AEB 0967 INCF encoder_1_count,1
0968 ; }
0969 ;
0970 ;
0971 ; if (encoder_2 != last_encoder_2)
0196 1283 0972 m032 BCF 0x03,RP0
0197 1303 0973 BCF 0x03,RP1
0198 1908 0974 BTFSC 0x08,encoder_2
0199 299D 0975 GOTO m033
019A 1A64 0976 BTFSC 0x64,last_encoder_2
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -