📄 map_bot.lst
字号:
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 1
ADDR CODE LINE SOURCE
0001
0002 ; CC5X Version 3.1J, Copyright (c) B Knudsen Data
0003 ; C compiler for the PICmicro family
0004 ; ************ 4. Sep 2006 0:09 *************
0005
0006 processor 16F871
0007 radix DEC
0008
0000 0009 INDF EQU 0x00
0001 0010 TMR0 EQU 0x01
0003 0011 STATUS EQU 0x03
0004 0012 FSR EQU 0x04
0005 0013 PORTA EQU 0x05
0085 0014 TRISA EQU 0x85
0006 0015 PORTB EQU 0x06
0086 0016 TRISB EQU 0x86
0005 0017 T0CS EQU 5
0000 0018 Carry EQU 0
0002 0019 Zero_ EQU 2
0005 0020 RP0 EQU 5
0006 0021 RP1 EQU 6
0007 0022 IRP EQU 7
0002 0023 T0IF EQU 2
0005 0024 T0IE EQU 5
0007 0025 GIE EQU 7
0081 0026 OPTION_REG EQU 0x81
0007 0027 PORTC EQU 0x07
0008 0028 PORTD EQU 0x08
0009 0029 PORTE EQU 0x09
000E 0030 TMR1L EQU 0x0E
000F 0031 TMR1H EQU 0x0F
0011 0032 TMR2 EQU 0x11
0018 0033 RCSTA EQU 0x18
0019 0034 TXREG EQU 0x19
001A 0035 RCREG EQU 0x1A
001E 0036 ADRESH EQU 0x1E
001F 0037 ADCON0 EQU 0x1F
0087 0038 TRISC EQU 0x87
0088 0039 TRISD EQU 0x88
0089 0040 TRISE EQU 0x89
0098 0041 TXSTA EQU 0x98
0099 0042 SPBRG EQU 0x99
009E 0043 ADRESL EQU 0x9E
009F 0044 ADCON1 EQU 0x9F
0006 0045 PEIE EQU 6
0000 0046 TMR1IF EQU 0
0001 0047 TMR2IF EQU 1
0004 0048 TXIF EQU 4
0005 0049 RCIF EQU 5
0006 0050 ADIF EQU 6
0000 0051 TMR1ON EQU 0
0001 0052 TMR1CS EQU 1
0003 0053 T1OSCEN EQU 3
0004 0054 T1CKPS0 EQU 4
0005 0055 T1CKPS1 EQU 5
0002 0056 TMR2ON EQU 2
0001 0057 OERR EQU 1
0004 0058 CREN EQU 4
0000 0059 ADON EQU 0
0002 0060 GO EQU 2
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 2
ADDR CODE LINE SOURCE
0006 0061 ADCS0 EQU 6
0007 0062 ADCS1 EQU 7
0000 0063 TMR1IE EQU 0
0001 0064 TMR2IE EQU 1
0004 0065 TXIE EQU 4
0005 0066 RCIE EQU 5
0006 0067 ADIE EQU 6
0000 0068 encoder_0 EQU 0
0001 0069 encoder_1 EQU 1
0002 0070 encoder_2 EQU 2
0003 0071 encoder_3 EQU 3
0001 0072 pwm_out_0 EQU 1
0002 0073 pwm_out_1 EQU 2
0005 0074 pwm_out_2 EQU 5
0004 0075 pwm_out_3 EQU 4
0024 0076 recv_buffer EQU 0x24
002F 0077 send_buffer EQU 0x2F
0043 0078 servo_pos EQU 0x43
0049 0079 pwm_value EQU 0x49
004D 0080 analog_low EQU 0x4D
0055 0081 analog_high EQU 0x55
005D 0082 cur_analog EQU 0x5D
005E 0083 servo_mode EQU 0x5E
005F 0084 cur_servo EQU 0x5F
0060 0085 pwm_cycle EQU 0x60
0061 0086 cur_recv_byte EQU 0x61
0062 0087 cur_send_byte EQU 0x62
0063 0088 read_timeout EQU 0x63
0000 0089 reading_data EQU 0
0065 0090 wait_analog EQU 0x65
0066 0091 update_timeout EQU 0x66
0067 0092 running_counter EQU 0x67
0068 0093 recv_counter EQU 0x68
0001 0094 last_valid EQU 1
0002 0095 last_encoder_0 EQU 2
0003 0096 last_encoder_1 EQU 3
0004 0097 last_encoder_2 EQU 4
0005 0098 last_encoder_3 EQU 5
0069 0099 last_dir EQU 0x69
006A 0100 encoder_0_count EQU 0x6A
006B 0101 encoder_1_count EQU 0x6B
006C 0102 encoder_2_count EQU 0x6C
006D 0103 encoder_3_count EQU 0x6D
006E 0104 encoder_0_speed EQU 0x6E
0071 0105 encoder_low EQU 0x71
0075 0106 encoder_high EQU 0x75
006F 0107 run_count EQU 0x6F
0070 0108 svrWREG EQU 0x70
0020 0109 svrSTATUS EQU 0x20
0021 0110 tmp EQU 0x21
0021 0111 dir EQU 0x21
0021 0112 s EQU 0x21
0022 0113 C1cnt EQU 0x22
0021 0114 s_2 EQU 0x21
0022 0115 C2cnt EQU 0x22
0021 0116 mask EQU 0x21
0023 0117 ch EQU 0x23
0118
0000 0119 ORG 0x0003
0003 2AB0 0120 GOTO main
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 3
ADDR CODE LINE SOURCE
0121
0122 ; FILE map_bot.c
0123 ;
0124 ;/*
0125 ; Robot Controller Source
0126 ; (C) 2006 Jason Hunt nulluser@gmail.com
0127 ;
0128 ; Version 0.01
0129 ;
0130 ; 16f871.h has been modified as follows:
0131 ;
0132 ; // original
0133 ; // #pragma chip PIC16F871, core 14, code 2048, ram 32 : 0xBF /0 /3
0134 ;
0135 ; #pragma chip PIC16F871, core 14, code 0x1F00, ram 32 : 0x1FF
0136 ; #pragma cdata[0] = 0x0180 + 0x0A // CLRF PCLATH, prepare for code page change
0137 ; #pragma cdata[1] = 0 // NOP
0138 ; #pragma cdata[2] = 0 // NOP
0139 ; #pragma resetVector 3 // start address for user program
0140 ;
0141 ; This reserves space for the serial bootloader.
0142 ;*/
0143 ;
0144 ;#include <int16cxx.h>
0145 ;
0146 ;#pragma chip PIC16f871
0147 ;#pragma config |= 0x3FF2 // For 20 mhz ceramic resinator
0148 ;
0149 ;
0150 ;#define NUM_RECV_BYTES 11 // Bytes in control packet
0151 ;#define NUM_SEND_BYTES 20 // Bytes in telemetery packet
0152 ;
0153 ;#define NUM_SERVOS 6 // Number of servo outputs
0154 ;
0155 ;#define NUM_ANALOG 8
0156 ;
0157 ;/* Pin Assignments */
0158 ;
0159 ;#pragma bit led_0 @ PORTB.6
0160 ;#pragma bit led_1 @ PORTB.7
0161 ;
0162 ;//#pragma bit encoder_0 @ PORTB.0 // digital in 0
0163 ;//#pragma bit encoder_1 @ PORTA.4
0164 ;//#pragma bit encoder_2 @ PORTE.0
0165 ;//#pragma bit encoder_3 @ PORTE.1
0166 ;
0167 ;#pragma bit encoder_0 @ PORTD.0 // digital in 0
0168 ;#pragma bit encoder_1 @ PORTD.1
0169 ;#pragma bit encoder_2 @ PORTD.2
0170 ;#pragma bit encoder_3 @ PORTD.3
0171 ;
0172 ;
0173 ;//#pragma bit digital_in_4 @ PORTE.2
0174 ;
0175 ;//#pragma bit radio_in_0 @ PORTD.6
0176 ;//#pragma bit radio_in_1 @ PORTD.7
0177 ;
0178 ;//#pragma bit open_collector_0 @ PORTB.4
0179 ;//#pragma bit open_collector_1 @ PORTB.5
0180 ;
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 4
ADDR CODE LINE SOURCE
0181 ;/* Pin assignments for PWM */
0182 ;#pragma bit pwm_out_0 @ PORTB.1
0183 ;#pragma bit pwm_out_1 @ PORTB.2
0184 ;#pragma bit pwm_out_2 @ PORTB.5
0185 ;#pragma bit pwm_out_3 @ PORTB.4
0186 ;
0187 ;/* Data buffers for serial */
0188 ;unsigned char recv_buffer[NUM_RECV_BYTES];
0189 ;unsigned char send_buffer[NUM_SEND_BYTES];
0190 ;
0191 ;unsigned char servo_pos[NUM_SERVOS]; // Servo Positions
0192 ;unsigned char pwm_value[4]; // PWM Dutysw
0193 ;
0194 ;unsigned char analog_low[8]; // Analog low bytes
0195 ;unsigned char analog_high[8]; // Analog high bytes
0196 ;
0197 ;
0198 ;unsigned char cur_analog; // Current analog capture
0199 ;
0200 ;unsigned char servo_mode; // Current state of the servo interrupt system
0201 ;unsigned char cur_servo; // Current servo
0202 ;unsigned char pwm_cycle; // CUrrent PWM cutoff value
0203 ;
0204 ;unsigned char cur_recv_byte; // Index of recv buffer
0205 ;unsigned char cur_send_byte; // Index of send buffer
0206 ;unsigned char read_timeout; // Timeout counter
0207 ;bit reading_data; // True if reading
0208 ;
0209 ;unsigned char wait_analog; // True if waiting to start converstion
0210 ;
0211 ;unsigned char update_timeout;
0212 ;
0213 ;unsigned char running_counter;
0214 ;unsigned char recv_counter;
0215 ;bit last_valid;
0216 ;
0217 ;
0218 ;bit last_encoder_0;
0219 ;bit last_encoder_1;
0220 ;bit last_encoder_2;
0221 ;bit last_encoder_3;
0222 ;
0223 ;
0224 ;
0225 ;unsigned char last_dir;
0226 ;
0227 ;unsigned char encoder_0_count;
0228 ;unsigned char encoder_1_count;
0229 ;unsigned char encoder_2_count;
0230 ;unsigned char encoder_3_count;
0231 ;
0232 ;unsigned char encoder_0_speed;
0233 ;
0234 ;
0235 ;unsigned char encoder_low[4];
0236 ;unsigned char encoder_high[4];
0237 ;
0238 ;
0239 ;unsigned char run_count;
0240 ;
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 5
ADDR CODE LINE SOURCE
0241 ;/*******************
0242 ;** Interrupt Code **
0243 ;*******************/
0244 ;
0245 ;#pragma interruptSaveCheck n
0246 ;#pragma origin 4
0000 0247 ORG 0x0004
0248 ;
0249 ;
0250 ;
0251 ;
0252 ;
0253 ;/* the ISR to update the servos */
0254 ;interrupt ISR(void)
0255 ;{
0256 ISR
0257 ; int_save_registers
0004 00F0 0258 MOVWF svrWREG
0005 0E03 0259 SWAPF STATUS,W
0006 1283 0260 BCF 0x03,RP0
0007 1303 0261 BCF 0x03,RP1
0008 00A0 0262 MOVWF svrSTATUS
0263 ;
0264 ; if (RCIF)
0009 1E8C 0265 BTFSS 0x0C,RCIF
000A 28CD 0266 GOTO m011
0267 ; {
0268 ; RCIF = 0;
000B 128C 0269 BCF 0x0C,RCIF
0270 ; reading_data = 1;
000C 1464 0271 BSF 0x64,reading_data
0272 ; read_timeout = 0;
000D 01E3 0273 CLRF read_timeout
0274 ;
0275 ; // Eat data and timeout if sync is off
0276 ; if (!last_valid)
000E 18E4 0277 BTFSC 0x64,last_valid
000F 2818 0278 GOTO m001
0279 ; {
0280 ; recv_buffer[cur_recv_byte++] = RCREG;
0010 3024 0281 MOVLW .36
0011 0761 0282 ADDWF cur_recv_byte,W
0012 0084 0283 MOVWF FSR
0013 1383 0284 BCF 0x03,IRP
0014 081A 0285 MOVF RCREG,W
0015 0080 0286 MOVWF INDF
0016 0AE1 0287 INCF cur_recv_byte,1
0288 ; cur_recv_byte = 0;
0017 01E1 0289 CLRF cur_recv_byte
0290 ; }
0291 ;
0292 ;
0293 ; // Send current telemetry data for the first char recevied
0294 ; // This will utilize full duplex for better transfer
0295 ; if (cur_recv_byte == 0 && last_valid)
0018 1283 0296 m001 BCF 0x03,RP0
0019 1303 0297 BCF 0x03,RP1
001A 08E1 0298 MOVF cur_recv_byte,1
001B 1D03 0299 BTFSS 0x03,Zero_
001C 2867 0300 GOTO m002
CC5X Version 3.1J, File: map_bot.c 4. Sep 2006 0:09 Page 6
ADDR CODE LINE SOURCE
001D 1CE4 0301 BTFSS 0x64,last_valid
001E 2867 0302 GOTO m002
0303 ; {
0304 ; // Package current telemetry data for transmittion
0305 ; // Start byte
0306 ; send_buffer[0] = 0xff;
001F 30FF 0307 MOVLW .255
0020 00AF 0308 MOVWF send_buffer
0309 ;
0310 ; // Low bytes of analog data
0311 ; send_buffer[1] = analog_low[0];
0021 084D 0312 MOVF analog_low,W
0022 00B0 0313 MOVWF send_buffer+1
0314 ; send_buffer[2] = analog_low[1];
0023 084E 0315 MOVF analog_low+1,W
0024 00B1 0316 MOVWF send_buffer+2
0317 ; send_buffer[3] = analog_low[2];
0025 084F 0318 MOVF analog_low+2,W
0026 00B2 0319 MOVWF send_buffer+3
0320 ; send_buffer[4] = analog_low[3];
0027 0850 0321 MOVF analog_low+3,W
0028 00B3 0322 MOVWF send_buffer+4
0323 ; send_buffer[5] = analog_low[4];
0029 0851 0324 MOVF analog_low+4,W
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -