Searching \ for '16c74 serial port help!' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=serial
Search entire site for: '16c74 serial port help!'.

Truncated match.
PICList Thread
'16c74 serial port help!'
1998\02\11@113005 by Mike Barrett

flavicon
face
First thanks  for all the info for accessing text string, it seems there is
no easy way to do it.

I now have another problem I am using a 16c74 and have got to send the data
from the A/D down the serial port. I now want to do is to send it commands
(from a PC) and for the program the  to act on those commands.
The first thing I have tried is to get the program it to echo back what has
been sent down the serial line, but I cant get this to work! The program
sends data perfectly what I cant seem to get it to do is to recieve a byte
and then send it back. I have included part of the code below,
I know I am not checking for errors but I just want to  keep it simple to
start with ( maybe I cant..). If there are some obvious errors please show
me....
My 3 main question are
1) Do I check the RCIF bit to see if data is in the RCREG, or is there
another way?
2) Do I have to do anything else to read the RCREG, do I need to clear it
after wards?
3) Does anyone have a example bit of working code I could try!!

All help gratefully received.

Thanks

Mike Barrett


; start of code to echo back data from RX port to TX port
; data is 1 ascii character

       CALL    SERIAL_SETUP

A1                              ;START HERE
       BTFSS   PIR1,RCIF       ; SEE IF DATA IN BUFFER, SET IF DATA
       GOTO    NO_DATA
       MOVF    RCREG,W ; MOVE DATA INTO W
       MOVWF   TX_CHAR
       call    serial_send     ; byte in TX_CHAR this sub works
NO_DATA
       GOTO    A1              ; RETURN TO START OF LOOP

;
; SETUP SERIAL PORT AND BAUD RATE
;
SERIAL_SETUP
       BSF     RCSTA,SPEN      ; ENABLE RC6,RC7 SERIAL COMMUNICTION
       BSF     RCSTA,RX9       ; SET FOR 9 BIT RX DATA
       BSF     RCSTA,CREN      ; ENABLE RX
       BCF     STATUS,BIT6     ; BANK 1
       BSF     STATUS,BIT5     ; SETUP FOR MEMORY BANK
       BSF     TXSTA,TXEN      ; ENABLE TX
       BSF     TXSTA,TX9       ; SET TX LENGTH TO 9 BITS
       BCF     TXSTA,TX9D      ; 9 BIT SET LOW
       BCF     TXSTA,BRGH      ; SET BAUD RATE low
       MOVLW   H'0C'           ; 12 BAUD RATE FOR 4800
       MOVWF   SPBRG           ; MOVE TO BAUD RATE GENERATOR
       BCF     TXSTA,SYNC      ; SET SYNC TO  ASYNCHRONOUS MODE
       BCF     STATUS,BIT6     ; BANK 0
       BCF     STATUS,BIT5     ; SETUP FOR MEMORY BANK
RETURN

=============================================
Mike Barrett                E-mail: spam_OUTbarrettTakeThisOuTspamcambridge.scr.slb.com
Schlumberger Cambridge Research      Phone: 01223 325200
High Cross,  Cambridge, CB3 OEL. U.K    Fax: 01223 327019
=============================================

1998\02\11@114405 by Sean Breheny

face picon face
At 04:22 PM 2/11/98 +0000, you wrote:
{Quote hidden}

<snip>

>        BSF     RCSTA,RX9       ; SET FOR 9 BIT RX DATA
>        BSF     RCSTA,CREN      ; ENABLE RX
>        BCF     STATUS,BIT6     ; BANK 1
>        BSF     STATUS,BIT5     ; SETUP FOR MEMORY BANK
>        BSF     TXSTA,TXEN      ; ENABLE TX
>        BSF     TXSTA,TX9       ; SET TX LENGTH TO 9 BITS
>        BCF     TXSTA,TX9D      ; 9 BIT SET LOW
<snip>

Mike, I didn't take a very hard look at this, but why are you sending and
receiving 9 bit data? Usually 8N1(8 data bits, no parity, 1 stop bit,
generated automatically by the USART in the PIC) is used with the PC serial
port.
I don't even think that PC serial port can generate 9 bit serial data (I'm
pretty sure it can't, just don't want to say absolutely SURE). You may not
be experiencing the trouble in sending data TO the PC because the PC may be
ignoring the 9th bit (if it happens to be the same polarity as the stop
bit, otherwise it would probably generate a framing error, which you might
not be detecting, and the received data might be ok, anyway).

Good luck,

Sean



+--------------------------------+
| Sean Breheny                   |
| Amateur Radio Callsign: KA3YXM |
| Electrical Engineering Student |
+--------------------------------+
Fight injustice, please look at
http://homepages.enterprise.net/toolan/joanandrews/

Personal page: http://www.people.cornell.edu/pages/shb7
.....shb7KILLspamspam@spam@cornell.edu
Phone(USA): (607) 253-0315

1998\02\11@121941 by Jim Main

flavicon
picon face
-----Original Message-----
From: Mike Barrett <barrettspamKILLspamCAMBRIDGE.SCR.SLB.COM>
To: .....PICLISTKILLspamspam.....MITVMA.MIT.EDU <EraseMEPICLISTspam_OUTspamTakeThisOuTMITVMA.MIT.EDU>
Date: Wednesday, February 11, 1998 4:34 pm
Subject: 16c74 serial port help!

{Quote hidden}

At first glance, the above line should actually BSF   STATUS,BIT6  (not BCF)

Jim

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...