📄 m16_xmodem.s
字号:
_DATA_DOWNFINE::
.blkw 1
.area idata
.word L3
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e DATA_DOWNFINE _DATA_DOWNFINE pkc
_DATA_ERROR::
.blkw 1
.area idata
.word L4
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e DATA_ERROR _DATA_ERROR pkc
_DATA_DOWNFINEOK::
.blkw 1
.area idata
.word L5
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e DATA_DOWNFINEOK _DATA_DOWNFINEOK pkc
_DATA_MMSTRACE::
.blkw 1
.area idata
.word L6
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e DATA_MMSTRACE _DATA_MMSTRACE pkc
_DATA_RING::
.blkw 1
.area idata
.word L7
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e DATA_RING _DATA_RING pkc
_DATA_CLIP::
.blkw 1
.area idata
.word L8
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e DATA_CLIP _DATA_CLIP pkc
_dial_number::
.blkb 2
.area idata
.byte 49,51
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.blkb 2
.area idata
.byte 55,54
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.blkb 2
.area idata
.byte 55,49
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.blkb 2
.area idata
.byte 51,49
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.blkb 2
.area idata
.byte 54,52
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.blkb 1
.area idata
.byte 49
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e dial_number _dial_number A[12:12]c
_subject::
.blkb 8
.area idata
.byte 'm,'m,'s,'t,'e,'s,'t,0
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e subject _subject A[8:8]c
_deletmms::
.blkb 14
.area idata
.byte 'A,'T,36,'F,'D,'E,'L,61,34,42,34,13,10,0
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e deletmms _deletmms A[14:14]c
_receive_sp::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e receive_sp _receive_sp I
.area text(rom, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 112
; //ICC-AVR application builder : 2008-7-29 下午 04:04:26
; // Target : M16
; // Crystal: 3.6864Mhz
;
; #include <iom16v.h>
; #include <macros.h>
; #include "pic_crc_data.h"
;
;
; #define true 1
; #define false 0
; #define uchar unsigned char
; #define uint unsigned int
; #define ulong unsigned long
;
; #define SOH 0x01
; #define EOT 0x04
; #define ACK 0x06
; #define NAK 0x15
; #define CAN 0x18
; #define CTRL_Z 0x1a
; #define SPACE 0x20
; #define ASCII_C 0x43
; #define ENTER 0x0d
; #define CHARGE_LINE 0x0a
; #define PACKET_DATA_BUFFER_LENGTH 128
; #define MAX_TX_TRY 3
; #define ctrl_z 0x1a
;
; uchar const *DATA_AT = "at$";
; uchar const *DATA_OK = "OK";
; uchar const *DATA_DOWNFINE = "Ok_Info_FileUploadStarted";
; uchar const *DATA_ERROR = "ERROR";
; uchar const *DATA_DOWNFINEOK = "Ok_Info_FileClose";
; uchar const *DATA_MMSTRACE = "$MMSTRACE: 1";
; uchar const *DATA_RING = "RING";
; uchar const *DATA_CLIP = "+CLIP";
;
;
; uchar dial_number[12]={'1','3','7','6','7','1','3','1','6','4','1'};
; uchar subject[]="mmstest";
; uchar deletmms[]="AT$FDEL=\"*\"\r\n" ;
;
;
; uchar receive_OK;
; uchar receive_other;
; uchar receive_C;
; uchar receive_DAYUHAO;
; uchar receive_DOWNFINE;
; uchar receive_DOWNFINEOK;
; uchar receive_ERROR;
; uchar receive_MMSTRACE;
; uchar receive_RING;
; uchar receive_CLIP;
;
; uchar flag_mobile;
; uchar flag_telephone;
; uchar telephone_long;
;
;
; uchar xmodedata; // TH
; uint picLenth; // TH
; uchar test[100];
;
;
;
; #define PRINT_BUFFER_LENGTH 80
; #define COUNT_STEP 1
; #define MAX_COUNT 100
; #define MAX_MESSAGE_LEN 132
;
; struct Message
; {
; uchar Data_Len; /* 消息内容长度,即Message中的内容字节数 */
; uchar Message[PACKET_DATA_BUFFER_LENGTH]; /* 消息内容, 由发送进程填写 */
; uint User_Data;
;
; };
;
; #define STRING_LENGTH 40
; struct String
; {
; uint string_len;
; uchar string[STRING_LENGTH];
; void *string_data;
; };
;
;
;
; uchar sending;
; uchar receive_data[STRING_LENGTH];
; int receive_sp=0;
;
; uchar const *pic;
;
; void intDelay(uint i);
; uint update_CRC(uchar inData, uint checksum);
; uchar tx_EOT(void);
; void Delay(unsigned int Delay_MS);
;
; void send_m_byte(uchar *string, uint length);
; void send_a_byte(uchar temp);
; void do_serial_data(void);
; uchar send_packet_data(uchar const *User_Data , uint LEN);
; uchar tx_packet(uchar packet_number,uchar * packet_data_buffer, uchar temp_char );
; void sendcmd(unsigned char *by_Array);
; void mms_atsent(void);
; void Xmodem(void);
;
;
; void port_init(void)
; {
.dbline 113
; PORTA = 0x00;
clr R2
out 0x1b,R2
.dbline 114
; DDRA = 0x00;
out 0x1a,R2
.dbline 115
; PORTB = 0x00;
out 0x18,R2
.dbline 116
; DDRB = 0x00;
out 0x17,R2
.dbline 117
; PORTC = 0x00; //m103 output only
out 0x15,R2
.dbline 118
; DDRC = 0x00;
out 0x14,R2
.dbline 119
; PORTD = 0x00;
out 0x12,R2
.dbline 120
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L9:
.dbline 0 ; func end
ret
.dbend
.dbfunc e uart0_init _uart0_init fV
.even
_uart0_init::
.dbline -1
.dbline 127
; }
;
; //UART0 initialize
; // desired baud rate: 9600
; // actual: baud rate:9600 (0.0%)
; void uart0_init(void)
; {
.dbline 128
; UCSRB = 0x00; //disable while setting baud rate
clr R2
out 0xa,R2
.dbline 129
; UCSRA = 0x00;
out 0xb,R2
.dbline 130
; UCSRC = BIT(URSEL) | 0x06;
ldi R24,134
out 0x20,R24
.dbline 131
; UBRRL = 0x01; //set baud rate lo
ldi R24,1
out 0x9,R24
.dbline 132
; UBRRH = 0x00; //set baud rate hi
out 0x20,R2
.dbline 133
; UCSRB = 0x98;
ldi R24,152
out 0xa,R24
.dbline -2
L10:
.dbline 0 ; func end
ret
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 138
; }
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 140
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 141
; port_init();
xcall _port_init
.dbline 142
; uart0_init();
xcall _uart0_init
.dbline 144
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 145
; GICR = 0x00;
out 0x3b,R2
.dbline 146
; TIMSK = 0x00; //timer interrupt sources
out 0x39,R2
.dbline 147
; SEI(); //re-enable interrupts
sei
.dbline -2
L11:
.dbline 0 ; func end
ret
.dbend
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
_temp_char0::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbsym e temp_char0 _temp_char0 c
.area vector(rom, abs)
.org 44
jmp _uart0_rx_isr
.area data(ram, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.area text(rom, con, rel)
.dbfile F:\GPRS资料\M16_Xmodem\m16_Xmodem.c
.dbfunc e uart0_rx_isr _uart0_rx_isr fV
; temp -> R10
.even
_uart0_rx_isr::
st -y,R0
st -y,R1
st -y,R2
st -y,R3
st -y,R4
st -y,R5
st -y,R6
st -y,R7
st -y,R8
st -y,R9
st -y,R16
st -y,R17
st -y,R18
st -y,R19
st -y,R24
st -y,R25
st -y,R26
st -y,R27
st -y,R30
st -y,R31
in R0,0x3f
st -y,R0
st -y,R10
.dbline -1
.dbline 154
; //all peripherals are now initialized
; }
;
; uchar temp_char0=0;
; #pragma interrupt_handler uart0_rx_isr:iv_USART0_RXC
; void uart0_rx_isr(void)
; {
.dbline 158
; //uart has received a character in UDR
; //uchar temp_char0;
; unsigned char temp;
; temp=UDR;
in R10,0xc
.dbline 159
; temp_char0 = temp;
sts _temp_char0,R10
.dbline 160
; if(temp_char0 == 'C')
mov R24,R10
cpi R24,67
brne L13
X0:
.dbline 161
; { //检测是否收到 C
.dbline 162
; receive_C = 1;
ldi R24,1
sts _receive_C,R24
.dbline 164
;
; }
L13:
.dbline 165
; if(temp_char0 == '>')
lds R24,_temp_char0
cpi R24,62
brne L15
X1:
.dbline 166
; { //检测是否收到 >
.dbline 167
; receive_DAYUHAO = 1;
ldi R24,1
sts _receive_DAYUHAO,R24
.dbline 168
; }
L15:
.dbline 169
; if(temp_char0 == 'K')
lds R24,_temp_char0
cpi R24,75
brne L17
X2:
.dbline 170
; { //检测是否收到 OK
.dbline 171
; receive_OK = 1;
ldi R24,1
sts _receive_OK,R24
.dbline 172
; }
L17:
.dbline 173
; if(temp_char0 == '1')
lds R24,_temp_char0
cpi R24,49
brne L19
X3:
.dbline 174
; { //检测是否收到 $MMSTRACE: 1
.dbline 175
; receive_MMSTRACE = 1;
ldi R24,1
sts _receive_MMSTRACE,R24
.dbline 176
; }
L19:
.dbline 177
; if(temp_char0 == 'U')
lds R24,_temp_char0
cpi R24,85
brne L21
X4:
.dbline 178
; { //检测是否收到 DOWNFINE
.dbline 179
; receive_DOWNFINE = 1;
ldi R24,1
sts _receive_DOWNFINE,R24
.dbline 180
; }
L21:
.dbline 181
; if(temp_char0 == 'R')
lds R24,_temp_char0
cpi R24,82
brne L23
X5:
.dbline 182
; { //检测是否收到 RING
.dbline 183
; receive_RING = 1;
ldi R24,1
sts _receive_RING,R24
.dbline 184
; }
L23:
.dbline 185
; if(temp_char0 == '+')
lds R24,_temp_char0
cpi R24,43
brne L25
X6:
.dbline 186
; { //检测是否收到 CLIP
.dbline 187
; receive_CLIP = 1;
ldi R24,1
sts _receive_CLIP,R24
.dbline 188
; }
L25:
.dbline 189
; if ((temp_char0 == CHARGE_LINE)|| (temp_char0 == ENTER))
lds R2,_temp_char0
mov R24,R2
cpi R24,10
breq L29
X7:
cpi R24,13
brne L27
X8:
L29:
.dbline 190
; {
.dbline 191
; do_serial_data(); //收到回车,接收指针归零 ,并处理接收数据
xcall _do_serial_data
.dbline 192
; receive_sp = 0;
clr R2
clr R3
sts _receive_sp+1,R3
sts _receive_sp,R2
.dbline 193
; }
xjmp L28
L27:
.dbline 195
; else
; {
.dbline 196
; receive_data[receive_sp++] =temp;
lds R2,_receive_sp
lds R3,_receive_sp+1
movw R24,R2
adiw R24,1
sts _receive_sp+1,R25
sts _receive_sp,R24
ldi R24,<_receive_data
ldi R25,>_receive_data
movw R30,R2
add R30,R24
adc R31,R25
std z+0,R10
.dbline 197
; }
L28:
.dbline 198
; if (receive_sp > 40) //接收超长,接收指针规零
ldi R24,40
ldi R25,0
lds R2,_receive_sp
lds R3,_receive_sp+1
cp R24,R2
cpc R25,R3
brge L30
X9:
.dbline 199
; receive_sp = 0;
clr R2
clr R3
sts _receive_sp+1,R3
sts _receive_sp,R2
L30:
.dbline -2
L12:
.dbline 0 ; func end
ld R10,y+
ld R0,y+
out 0x3f,R0
ld R31,y+
ld R30,y+
ld R27,y+
ld R26,y+
ld R25,y+
ld R24,y+
ld R19,y+
ld R18,y+
ld R17,y+
ld R16,y+
ld R9,y+
ld R8,y+
ld R7,y+
ld R6,y+
ld R5,y+
ld R4,y+
ld R3,y+
ld R2,y+
ld R1,y+
ld R0,y+
reti
.dbsym r temp 10 c
.dbend
.dbfunc e main _main fV
; i -> R20,R21
.even
_main::
.dbline -1
.dbline 212
;
; }
;
;
;
;
;
; /*********************************************************************
;
; *********************************************************************/
;
; void main(void)
; {
.dbline 215
; int i;
;
; init_devices();
xcall _init_devices
.dbline 217
;
; for(i = 0; i< STRING_LENGTH ; i++) //清接收缓存//40
clr R20
clr R21
L33:
.dbline 218
; {
.dbline 219
; receive_data[i] = 0;
ldi R24,<_receive_data
ldi R25,>_receive_data
movw R30,R20
add R30,R24
adc R31,R25
clr R2
std z+0,R2
.dbline 220
; }
L34:
.dbline 217
subi R20,255 ; offset = 1
sbci R21,255
.dbline 217
cpi R20,40
ldi R30,0
cpc R21,R30
brlt L33
X10:
.dbline 222
;
; receive_OK = 0;
clr R2
sts _receive_OK,R2
.dbline 223
; send_a_byte(ENTER); //发送回车,测试模块
ldi R16,13
xcall _send_a_byte
.dbline 224
; Delay(500);
ldi R16,500
ldi R17,1
xcall _Delay
.dbline 226
;
; receive_OK = 0;
clr R2
sts _receive_OK,R2
.dbline 227
; send_m_byte("at\r\n",4); //发送AT,测试模块
ldi R18,4
ldi R19,0
ldi R16,<L37
ldi R17,>L37
xcall _send_m_byte
.dbline 228
; send_a_byte(ENTER);
ldi R16,13
xcall _send_a_byte
xjmp L39
L38:
.dbline 231
;
; while(receive_OK== 0)
; {
.dbline 232
; send_a_byte(ENTER);
ldi R16,13
xcall _send_a_byte
.dbline 233
; Delay(1000);
ldi R16,1000
ldi R17,3
xcall _Delay
.dbline 234
; }
L39:
.dbline 230
lds R2,_receive_OK
tst R2
breq L38
X11:
.dbline 235
; receive_RING=0;
clr R2
sts _receive_RING,R2
.dbline 236
; receive_CLIP=0;
sts _receive_CLIP,R2
xjmp L42
L41:
.dbline 238
; while(1)
; {
.dbline 239
; Delay(10);
ldi R16,10
ldi R17,0
xcall _Delay
xjmp L45
L44:
.dbline 242
;
; while((receive_RING==1)&&(receive_CLIP==1))
; { Delay(10);
.dbline 242
ldi R16,10
ldi R17,0
xcall _Delay
.dbline 244
;
; receive_OK = 0;
clr R2
sts _receive_OK,R2
.dbline 245
; send_m_byte("ath\r\n",5);
ldi R18,5
ldi R19,0
ldi R16,<L47
ldi R17,>L47
xcall _send_m_byte
L48:
.dbline 246
; while(receive_OK == 0) ;
L49:
.dbline 246
lds R2,_receive_OK
tst R2
breq L48
X12:
.dbline 247
; Xmodem();
xcall _Xmodem
.dbline 249
;
; Delay(10);
ldi R16,10
ldi R17,0
xcall _Delay
.dbline 250
; mms_atsent();
xcall _mms_atsent
.dbline 252
;
; receive_RING=0;
clr R2
sts _receive_RING,R2
.dbline 253
; receive_CLIP=0;
sts _receive_CLIP,R2
.dbline 254
; }
L45:
.dbline 241
lds R24,_receive_RING
cpi R24,1
brne L51
X13:
lds R24,_receive_CLIP
cpi R24,1
breq L44
X14:
L51:
.dbline 255
; }
L42:
.dbline 237
xjmp L41
X15:
.dbline -2
L32:
.dbline 0 ; func end
ret
.dbsym r i 20 I
.dbend
.dbfunc e send_a_byte _send_a_byte fV
; data -> R16
.even
_send_a_byte::
.dbline -1
.dbline 265
;
;
;
; }
;
;
;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -