Help me code EUART pic16f883 asm

Thread Starter

kidteam

Joined Dec 22, 2011
1
hi all
i'm try code asm with pic16f883
code transmit
code
Rich (BB code):
#include p16f883.inc
__config _CONFIG1, _FOSC_XT& _WDTE_OFF& _PWRTE_OFF& _MCLRE_OFF& _CP_OFF& _CPD_OFF& _BOR_OFF& _IESO_OFF& _FCMEN_OFF& _LVP_OFF& _DEBUG_OFF
__config _CONFIG2, _BOR21V& _WRT_OFF
;thach anh 3.686400 MHz
		c1			equ			0x20
		c2			equ			0x21
		c3			equ			0x22
		org			0x0000
		goto		start
start
		banksel		ANSEL
		clrf		ANSEL
		clrf		ANSELH
		banksel		TXSTA
		bsf			TXSTA,		TXEN
		bcf			TXSTA,		SYNC
		banksel		RCSTA
		bsf			RCSTA,		RCEN
		bsf			RCSTA,		SPEN
		banksel		SPBRG
		clrf		SPBRGH
		movlw		d'5'
		movwf		SPBRG
main
		banksel		PIR1
		btfss		PIR1,		TXIF
		goto		$-1
		banksel		TXREG
		movlw		'K'
		movwf		TXREG
		call		delay
		goto		main
;--------------------------------------------------------------
delay
		banksel		0
		movlw		100
		movwf		c1
loop2
		movlw		50
		movwf		c2
loop1
		movlw		3
		movwf		c3
		decfsz		c3,			1
		goto		$-1
		decfsz		c2,			1
		goto		loop1
		decfsz		c1,			1
		goto		loop2
		return
;==============================================================
				
end
is work fine
can i help me code receive.
Please help me.
 

joev

Joined Jan 11, 2013
1
You're almost done. Once you get the transmit to work, you've verified that the baud rate is correct. You've already go the receiver enabled (RCEN, SPEN). Now just poll RCIF for received data and read RCREG.
 
Top