hư ớ ng dẫ n về dsp tham khả o các cô ng cụ cơ bả n

源代码在线查看: vidu4-2.s

软件大小: 12 K
上传用户: bandagemaster
关键词: 7843 7899 7851 7873
下载地址: 免注册下载 普通下载 VIP

相关代码

				;*******************************************************************************
				;	Vidu4-2.s la chuong trinh viet bang hop ngu de chay tren mot dsPIC		   *
				;	Chuong trinh thuc hien viec sau: Doc ky tu tu cong RS232, sau do gui tra   *
				;	ky tu da duoc sua doi (cong 1 vao) ve thong qua cong RS232				   *
				;*******************************************************************************
				
				;	Tac gia				: Nguyen Quang Nam									   *
				
				;	Don vi				: PIC Viet Nam										   *
				
				;	Ten tap tin			: Vidu4-2.s											   *
				
				;	Ngay				: 09/08/2006										   *
				
				;	Phien ban			: 0.01												   *
				
				;	Nhung tap tin can thiet khac: p30F4012.gld, p30f4012.inc				   *
				
				;	Cong cu duoc dung:	MPLAB 7.31											   *
				;						ASM30 2.14											   *
				;						LNK30 2.14											   *
				;-------------------------------------------------------------------------------
				
				;	.equ __30F2010, 1
				;	.equ __30F2011, 1
				;	.equ __30F2012, 1
				;	.equ __30F3010, 1
				;	.equ __30F3011, 1
				;	.equ __30F3012, 1
				;	.equ __30F3013, 1
				;	.equ __30F3014, 1
				;	.equ __30F4011, 1
					.equ __30F4012, 1
				;	.equ __30F4013, 1
					.include "p30fxxxx.inc"
				
				;	config	__FOSC, CSW_FSCM_OFF & HS
				;	config	__FOSC, CSW_FSCM_OFF & HS2_PLL8
				;	config	__FOSC, CSW_FSCM_OFF & HS2_PLL16
				;	config	__FOSC, CSW_FSCM_OFF & FRC
					config	__FOSC, CSW_FSCM_OFF & FRC_PLL4
				;	config	__FOSC, CSW_FSCM_OFF & FRC_PLL8
				;	config	__FOSC, CSW_FSCM_OFF & XT_PLL8
				;	config	__FOSC, CSW_FSCM_OFF & XT_PLL16
					config	__FWDT, WDT_OFF
					config	__FBORPOR, MCLR_EN & PBOR_OFF
					config	__FGS, CODE_PROT_OFF
				
				;-------------------------------------------------------------------------------
				;Cac hang so cua chuong trinh (gia tri tuc thoi dung trong chuong trinh)
				
					.equiv	Fcy, 8000000	;Tan so thuc thi lenh
					.equiv	baud, 38400		;Toc do baud cua cong RS232
				
				;-------------------------------------------------------------------------------
				;Cac khai bao toan cuc:
				
					.global __reset			;Khai bao nhan bat dau chuong trinh (bat buoc)
				
				;-------------------------------------------------------------------------------
				;Doan ma trong vung nho chuong trinh
				
					.text				;Bat dau doan ma chuong trinh
				
				__reset:       
						mov	#__SP_init, W15	;Khoi tao con tro ngan xep (stack)
						mov	#__SPLIM_init, W0
						mov	W0, SPLIM	;Khoi tao thanh ghi gioi han con tro ngan xep (stack)
						nop				;Can mot lenh NOP sau khi ghi vao SPLIM
						clr	W0			;Xoa thanh ghi lam viec W0
						mov	W0, W14 	;Xoa cac thanh ghi W1 den W14
						repeat	#12
						mov	W0,[++W14]	;Dia chi cua cac thanh ghi: 0x0002 - 0x001C
						clr	W14
				
				;-------------------------------------------------------------------------------
						rcall	Init_UART1		;Khoi tao cong RS232 thu nhat
				
				main_loop:
						btss	U1STA, #URXDA	;Co ky tu gui den?
						bra	main_loop			;Khong, tiep tuc kiem tra
						mov	U1RXREG, W0			;Co, doc ky tu da nhan vao W0
						inc	W0, W0				;sua doi ky tu da nhan
						mov	W0, U1TXREG			;va ghi ky tu da sua doi ra cong RS232
						bra	main_loop			;Tro ve vong lap chinh
				;-------------------------------------------------------------------------------
				
				;Chuong trinh con khoi tao cong RS232 thu nhat (module UART1)
				;-------------------------------------------------------------------------------
				Init_UART1:
						mov	#0x8000, W0		;bit15=UARTEN  bit10=ALTIO, dung Main IO
						mov	W0, U1MODE
						mov	#0x0400, W0		;bit10=UTXEN
						mov	W0, U1STA
				        mov	#(((Fcy/baud)/16)-1), W0	;Khoi tao toc do baud
				        mov	W0, U1BRG					;=((Fcy/baud)/16) - 1)
						return
				;-------------------------------------------------------------------------------
				
					.end				;Ket thuc phan ma trong tap tin nay
							

相关资源