Title "USART TESTER"
;
; Author Claudio RACHIELE IW0DZG
;
; Working 20000318
;
list p=16f877,c=140 ; processor type
errorlevel 1, -(305)
#include "p16f877.inc"
__CONFIG _PWRTE_ON&_HS_OSC&_LVP_OFF&_WDT_OFF
temp equ 7Fh ;
;
; -----------
; DESCRIPTION
; -----------
;
; Baud Rate = 9600, No Parity, 8 bits & 1 Stop Bit
;
; -------------
; PROGRAM START
; -------------
;
org 0 ; startup = 0000H
clrf STATUS ; bank 0
goto BootStart
org 4
ISR goto 5 ;
org 5
;
; --------------------------------------------------
; SET UP THE PORTS TO SUIT YOUR CIRCUIT REQUIREMENTS
; --------------------------------------------------
;
BootStart
banksel PORTA ; bank0
movlw b'00000000'
movwf PORTA
movlw b'00000000'
movwf PORTB
movlw b'01000000'
movwf PORTC
movlw b'00000000'
movwf PORTD
movlw b'00000000'
movwf PORTE
banksel TRISA ; bank1
movlw b'00000001'
movwf TRISA
movlw b'00000000'
movwf TRISB
movlw b'11000000' ; set RC6 & RC7 as input
movwf TRISC
movlw b'00000000'
movwf TRISD
movlw b'11101000'
movwf TRISE
movlw b'00000111'
movwf ADCON1 ; porta inputs = digital not analog
;
; BAUD RATE SETTINGS
;
; Baud Values with BRGH = 0
; ((20000000/9600)/64)-1 = 32
; movlw d'207' ; 1200 baud @ 16 Mhz Fosc +0.16 err
; movlw d'103' ; 2400 baud @ 16 Mhz Fosc +0.16 err
; movlw d'25' ; 9600 baud @ 16 Mhz Fosc +0.16 err
; movlw d'12' ; 19200 baud @ 16 Mhz Fosc +0.16 err
; movlw d'255' ; 1200 baud @ 20 Mhz Fosc +1.73 err
; movlw d'129' ; 2400 baud @ 20 Mhz Fosc +0.16 err
; movlw d'32' ; 9600 baud @ 20 Mhz Fosc -1.36 err
; movlw d'15' ; 19200 baud @ 20 Mhz Fosc +1.73 err
; Baud Values with BRGH = 1
; ((20000000/9600)/16)-1 = 32
movlw d'129' ; 9600 baud @ 20 Mhz Fosc +0.16 err
movwf SPBRG
movlw b'00100100' ; brgh = 1
movwf TXSTA ; enable Async Transmission, set brgh
banksel RCSTA ; bank0
movlw b'10010000'
movwf RCSTA ; enable Async Reception
movf RCREG,w
movf RCREG,w
movf RCREG,w ; flush receive buffer
;
;
; ------------------------------------
; PROVIDE A SETTLING TIME FOR START UP
; ------------------------------------
;
clrf temp
Settle
decfsz temp
goto Settle
LWaitCom
call RecLoop ; wait and read from RS232
movwf PORTB ; show value for diagnostic purpose
TxLoop
nop
btfss PIR1,TXIF ;xmit buffer empty?
goto TxLoop ;no, wait
movwf TXREG
goto LWaitCom ; no
;
; ----------------------------
; RECEIVE CHARACTER FROM RS232
; ----------------------------
; This routine does not return until a character is received.
RecLoop
nop
btfss PIR1,RCIF ; check for received data
goto RecLoop
movf RCREG,w
return
end
Questions:
I have a problem with using CCP pins for measuring time difference between two pulls signals where by timer1 will bee running free and CCP1capture is red throw CCPR1H-CCPR1L and CCP2 throw CCPR2H-CCPR2L complementing CCPR1H-CCPR1L and adding it to CCPR2H-CCPR2L after converting to ASCII and display on LCD the time measurement constantly flatcars with what looks like a random number and back to accurate measurement+
Welcome any suggestions
Thanks Boz
Comments:
| file: /Techref/microchip/16F877/rs232-cr.htm, 4KB, , updated: 2009/4/30 13:18, local time: 2025/10/27 00:27,
216.73.216.22,10-3-83-201:LOG IN
|
| ©2025 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://www.piclist.com/Techref/microchip/16F877/rs232-cr.htm"> PIC Specific RS232 IO</A> |
| Did you find what you needed? |
|
o List host: MIT, Site host massmind.org, Top posters @none found - Page Editors: James Newton, David Cary, and YOU! * Roman Black of Black Robotics donates from sales of Linistep stepper controller kits. * Ashley Roll of Digital Nemesis donates from sales of RCL-1 RS232 to TTL converters. * Monthly Subscribers: Gregg Rew. on-going support is MOST appreciated! * Contributors: Richard Seriani, Sr. |
|
The Backwoods Guide to Computer Lingo |
.