⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.s

📁 AVR控制西门子MC39I的程序
💻 S
字号:
	.module main.c
	.area data(ram, con, rel)
_RecCount::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile E:\project\大坝\code\AVR\main.c
	.dbsym e RecCount _RecCount c
	.area text(rom, con, rel)
	.dbfile E:\project\大坝\code\AVR\main.c
	.dbfunc e Delay _Delay fV
;              n -> R20,R21
;              m -> R22,R23
;           time -> R16,R17
	.even
_Delay::
	xcall push_gset2
	.dbline -1
	.dbline 17
; #include <iom128v.h>
; #include <macros.h>
; #define fosc 8000000 //晶振8MHZ
; #define baud  9600	 //与指纹头通讯的波特率
; #define FrameCount  10
; #define uint unsigned int
; #define uchar unsigned char
; 
; #define Set485Rec PORTG |= (1<<2)
; #define Set485Send PORTG &= ~(1<<2) 
; 
; uchar RecComm[10];
; uchar SendComm[10];
; uchar RecCount=0;
; 
; void Delay(uint time)
; {
	.dbline 19
;     uint m,n;
; 	for(n=0;n<time;n++)
	clr R20
	clr R21
	xjmp L5
L2:
	.dbline 20
; 	{
	.dbline 21
	clr R22
	clr R23
	xjmp L9
L6:
	.dbline 21
L7:
	.dbline 21
	subi R22,255  ; offset = 1
	sbci R23,255
L9:
	.dbline 21
	cpi R22,0
	ldi R30,1
	cpc R23,R30
	brlo L6
	.dbline 22
L3:
	.dbline 19
	subi R20,255  ; offset = 1
	sbci R21,255
L5:
	.dbline 19
	cp R20,R16
	cpc R21,R17
	brlo L2
	.dbline -2
	.dbline 23
;        for(m=0;m<256;m++);
; 	}
; }
L1:
	xcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r n 20 i
	.dbsym r m 22 i
	.dbsym r time 16 i
	.dbend
	.dbfunc e Com0Init _Com0Init fV
	.even
_Com0Init::
	.dbline -1
	.dbline 26
; 
; void Com0Init(void)                                    //串口通讯初始化程序
; {
	.dbline 27
;      UCSR0B = 0x00; //设置波特率时关闭发送和接收
	clr R2
	out 0xa,R2
	.dbline 28
;      UCSR0A = 0x00;
	out 0xb,R2
	.dbline 29
; 	 UBRR0L=(fosc/16/(baud+1))%256;
	ldi R24,52
	out 0x9,R24
	.dbline 30
;      UBRR0H=(fosc/16/(baud+1))/256;
	sts 144,R2
	.dbline 31
;      UCSR0C=(1<<UCSZ01)|(1<<UCSZ00);          //8位数据+1位STOP位
	ldi R24,6
	sts 149,R24
	.dbline 32
;      UCSR0B=(1<<RXEN0)|(1<<TXEN0)|(1<<RXCIE0);            //允许发送和接收
	ldi R24,152
	out 0xa,R24
	.dbline -2
	.dbline 34
;      //UCSR0B=(1<<RXEN0)|(1<<TXEN0);
; }
L10:
	.dbline 0 ; func end
	ret
	.dbend
	.area vector(rom, abs)
	.org 72
	jmp _uart0_rx_isr
	.area text(rom, con, rel)
	.dbfile E:\project\大坝\code\AVR\main.c
	.dbfunc e uart0_rx_isr _uart0_rx_isr fV
	.even
_uart0_rx_isr::
	st -y,R2
	st -y,R24
	st -y,R25
	st -y,R30
	st -y,R31
	in R2,0x3f
	st -y,R2
	.dbline -1
	.dbline 38
; 
; #pragma interrupt_handler uart0_rx_isr:iv_USART0_RXC
; void uart0_rx_isr()
; {
L12:
	.dbline 39
L13:
	.dbline 39
	sbis 0xb,7
	rjmp L12
	.dbline 40
	WDR
	.dbline 41
	ldi R24,<_RecComm
	ldi R25,>_RecComm
	lds R30,_RecCount
	clr R31
	add R30,R24
	adc R31,R25
	in R2,0xc
	std z+0,R2
	.dbline 42
	lds R24,_RecCount
	subi R24,255    ; addi 1
	sts _RecCount,R24
	.dbline 43
	cpi R24,10
	brlo L15
	.dbline 43
	clr R2
	sts _RecCount,R2
L15:
	.dbline -2
	.dbline 44
;       while(!(UCSR0A & (1<<RXC0)));        
; 	  asm("WDR");
; 	  RecComm[RecCount] = UDR0;
;       RecCount++;
; 	  if(RecCount >= FrameCount) RecCount = 0;
; }
L11:
	ld R2,y+
	out 0x3f,R2
	ld R31,y+
	ld R30,y+
	ld R25,y+
	ld R24,y+
	ld R2,y+
	.dbline 0 ; func end
	reti
	.dbend
	.dbfunc e SendFrame0 _SendFrame0 fV
;              m -> R20
;           pTem -> R22,R23
;     CountFrame -> R10
;          Frame -> R20,R21
	.even
_SendFrame0::
	xcall push_gset3
	mov R10,R18
	movw R20,R16
	.dbline -1
	.dbline 47
; 
; void SendFrame0(uchar *Frame,uchar CountFrame)
; {
	.dbline 49
;    uchar *pTem,m;
;    pTem = Frame;
	movw R22,R20
	.dbline 50
;    Set485Send;
	lds R24,101
	andi R24,251
	sts 101,R24
	.dbline 51
;    Delay(100);
	ldi R16,100
	ldi R17,0
	xcall _Delay
	.dbline 52
;    for(m=0;m<CountFrame;m++)
	clr R20
	xjmp L21
L18:
	.dbline 53
;    {
	.dbline 54
;       asm("WDR");
	WDR
L22:
	.dbline 55
L23:
	.dbline 55
	sbis 0xb,5
	rjmp L22
	.dbline 56
	WDR
	.dbline 57
	movw R30,R22
	ldd R2,z+0
	out 0xc,R2
	.dbline 58
	subi R22,255  ; offset = 1
	sbci R23,255
	.dbline 59
L19:
	.dbline 52
	inc R20
L21:
	.dbline 52
	cp R20,R10
	brlo L18
	.dbline 60
; 	  while (!(UCSR0A & (1<<UDRE0)));
;       asm("WDR");
; 	  UDR0 = *pTem;
;       pTem++;
;    }
;    Set485Rec;
	lds R24,101
	ori R24,4
	sts 101,R24
	.dbline 61
;    Delay(100);
	ldi R16,100
	ldi R17,0
	xcall _Delay
	.dbline -2
	.dbline 62
; }
L17:
	xcall pop_gset3
	.dbline 0 ; func end
	ret
	.dbsym r m 20 c
	.dbsym r pTem 22 pc
	.dbsym r CountFrame 10 c
	.dbsym r Frame 20 pc
	.dbend
	.dbfunc e main _main fV
;              m -> R20
	.even
_main::
	.dbline -1
	.dbline 65
; 
; void main(void)
; {
	.dbline 67
;    	 uchar m;
; 	 for(m=0;m<10;m++)
	clr R20
	xjmp L29
L26:
	.dbline 68
	.dbline 69
	ldi R24,<_SendComm
	ldi R25,>_SendComm
	mov R30,R20
	clr R31
	add R30,R24
	adc R31,R25
	mov R24,R20
	subi R24,208    ; addi 48
	std z+0,R24
	.dbline 70
L27:
	.dbline 67
	inc R20
L29:
	.dbline 67
	cpi R20,10
	brlo L26
	.dbline 71
; 	 {
; 	    SendComm[m]=0x30+m;
; 	 }
; 	 DDRG |= (1<<2);
	lds R24,100
	ori R24,4
	sts 100,R24
	.dbline 72
; 	 SEI();
	sei
	.dbline 73
; 	 Com0Init();
	xcall _Com0Init
	.dbline 74
; 	 SendFrame0(SendComm,10);
	ldi R18,10
	ldi R16,<_SendComm
	ldi R17,>_SendComm
	xcall _SendFrame0
	.dbline 75
; 	 for(;;)
L30:
	.dbline 76
	.dbline 77
	.dbline 77
	.dbline 78
	.dbline 75
	.dbline 75
	xjmp L30
X0:
	.dbline -2
L25:
	.dbline 0 ; func end
	ret
	.dbsym r m 20 c
	.dbend
	.area bss(ram, con, rel)
	.dbfile E:\project\大坝\code\AVR\main.c
_SendComm::
	.blkb 10
	.dbsym e SendComm _SendComm A[10:10]c
_RecComm::
	.blkb 10
	.dbsym e RecComm _RecComm A[10:10]c

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -