Searching \ for '[PIC]: Serial Communication' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=serial
Search entire site for: 'Serial Communication'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: Serial Communication'
2000\10\04@162956 by Davor Tolja

flavicon
face
I'm a newbie using a PIC16F877 trying to develop serial
communications between the PIC and in this case, my PC.
I followed the instructions in section 10 in the manual and I
am pretty sure I have initialized the port properly as I do
receive some of the data sent.  The problem is that I only
get a couple of the characters sent and lose most of the
message.  This is what I have done below:  any suggestions?

;---------------------
; Main Program Loop
;---------------------
main
   call     init_ports            ; set up ports
   call     init_serial            ; set up serial comm
   call     displaymsg          ; display test message

done
   goto  done
end

;--------------------
; Initialize Ports
;--------------------
init_ports

       clrf      STATUS
       clrf      PORTC
       bsf      STATUS,RP0     ; select bank 1
       bsf      TRISC,7          ; set PORTC 7:6 for async mode
       bsf      TRISC,6
       bcf      STATUS,RP0 ; select bank 0
return

;-------------------------------------
; Initialize Serial Port
;-------------------------------------
init_serial

       banksel    SPBRG
       movlw      D'129'  ; set baud rate for 9600 Fosc 20 MHz
       movwf     SPBRG
       banksel    TXSTA
       bcf           TXSTA,SYNC ; set for asynchronous mode
       bsf           TXSTA,TXEN ; enable serial transmission
       bsf           TXSTA,BRGH ; set for high speed (async mode)
       banksel    RCSTA
       bsf           RCSTA,SPEN    ; serial port enabled
return

;-------------------
; Display Message
;-------------------
displaymsg

       clrf        FSR
loop
       movf      FSR,w
       incf        FSR,f
       call         showmsg
       iorlw       0                    ; check if end of message
       btfsc        STATUS,Z
       return
       movwf     TXREG       ; send data to register
goto  loop

;----------------------------
; Messages to be displayed
;----------------------------
showmsg

       addwf         PCL,f
       nop
       dt               "TEST MESSAGE",0

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\10\04@164900 by Byron A Jeff

face picon face
>
> I'm a newbie using a PIC16F877 trying to develop serial
> communications between the PIC and in this case, my PC.

The definitive reference for the PIC UART is Fr. Tom McGahee's PICUART.ZIP
which is an annotated source for controlling the PIC UART. It can be found at
http://mcgahee.freeservers.com/ under the link PICUART.ZIP.

Hope this helps,

BAJ

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\10\04@175012 by Tony Nixon

flavicon
picon face
Davor Tolja wrote:
>
> I'm a newbie using a PIC16F877 trying to develop serial
> communications between the PIC and in this case, my PC.
> I followed the instructions in section 10 in the manual and I
> am pretty sure I have initialized the port properly as I do
> receive some of the data sent.  The problem is that I only
> get a couple of the characters sent and lose most of the
> message.  This is what I have done below:  any suggestions?


Most likely, the data is being sent to the TXREG before it has a chance
to send it out. It takes a certain amount of time to shift the data out,
depending on the baud rate.

This is a non interrupt method of waiting for all TX to finish.

;-------------------
; Display Message
;-------------------
displaymsg

       clrf        FSR
loop
       movf      FSR,w
       incf        FSR,f
       call         showmsg
       iorlw       0                    ; check if end of message
       btfsc        STATUS,Z
       return
       movwf     TXREG       ; send data to register
       call TransWt    ; <<<<<<<<<<<<<<<<<<<<<<
       goto  loop

;
; ------------------------------------
; WAIT UNTIL RS232 IS FINISHED SENDING
; ------------------------------------
;
TransWt bsf STATUS,RP0
WtHere  btfss TXSTA,TRMT                ; (1) transmission is complete if hi
       goto WtHere
;
       clrf STATUS             ; RAM Page 0
       return


--
Best regards

Tony

ICmicro's
http://www.picnpoke.com
spam_OUTsalesTakeThisOuTspampicnpoke.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\10\04@181121 by Davor Tolja

flavicon
face
Thank you for your suggestions.  The reference Byron directed me
to will prove to be very useful and I noticed Tony's contributions
in that savme document as well.  So if that won't be able to help me,
then nothing will.  Thanks again guys.

davor

{Quote hidden}

hi
{Quote hidden}

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\10\04@234943 by staff

flavicon
face
Davor Tolja wrote:
>
> Thank you for your suggestions.  The reference Byron directed me
> to will prove to be very useful and I noticed Tony's contributions
> in that savme document as well.  So if that won't be able to help me,
> then nothing will.  Thanks again guys.
>
> davor

One other thing, try running your PC side software in dos after
re-booting
in dos mode. Windows takes huge chunks of timeslice and isn't real
polite
about the ways it does it.
-Roman

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
"[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's


2000\10\05@003216 by Tony Nixon

flavicon
picon face
Roman Black wrote:
>
> One other thing, try running your PC side software in dos after
> re-booting
> in dos mode. Windows takes huge chunks of timeslice and isn't real
> polite
> about the ways it does it.
> -Roman
>
> --
> http://www.piclist.com hint: PICList Posts must start with ONE topic:
> "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's

The best way around Windows is to send data in 8 or 16 byte 'chunks' and
then ACK the transfer. I've never(??) had any problems thus far.

--
Best regards

Tony

ICmicro's
http://www.picnpoke.com
salesspamKILLspampicnpoke.com

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\10\05@023236 by Dan Michaels
flavicon
face
Roman Black wrote:
>Davor Tolja wrote:
>>
>> Thank you for your suggestions.  The reference Byron directed me
>> to will prove to be very useful and I noticed Tony's contributions
>> in that savme document as well.  So if that won't be able to help me,
>> then nothing will.  Thanks again guys.
>>
>> davor
>
>One other thing, try running your PC side software in dos after
>re-booting
>in dos mode. Windows takes huge chunks of timeslice and isn't real
>polite
>about the ways it does it.
>
>Roman
>

Yes, I have a DOS program that does RS-232 comm, and can run
successfully under Windows9x. Since the transferred data is
displayed graphically, you can easily estimate the amount of
time and frequency that Windows commandeers the cpu [for
backgnd/maintenance processing] by looking at data dropouts
- it's a "lot". To avoid data dropout, you have to disable
interrupts on the PC. [the clock gets a little off kilter,
but what the heck].

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\10\05@042228 by staff

flavicon
face
Tony Nixon wrote:
>
> Roman Black wrote:
> >
> > One other thing, try running your PC side software in dos after
> > re-booting
> > in dos mode. Windows takes huge chunks of timeslice and isn't real
> > polite
> > about the ways it does it.
> > -Roman
> >
> > --
> > http://www.piclist.com hint: PICList Posts must start with ONE topic:
> > "[PIC]:" PIC only "[EE]:" engineering "[OT]:" off topic "[AD]:" ad's
>
> The best way around Windows is to send data in 8 or 16 byte 'chunks' and
> then ACK the transfer. I've never(??) had any problems thus far.
>

The best way around windows is to delete it and run your app under
dos. I write a lot of CNC and industrial control stuff using turbo C
for dos and dos 6. Amazing just how fast your PC can do stuff if it
doesn't have crappy operating system built by committees paid per code
size and spending all their time blaming problems on the "other" group
instead of making it PERFORM. I have written huge apps that load
themselves and Mb of data, config etc in 0.1 seconds. So why does my
word processor take 7.8 seconds to start up before I can even start
typing a simple letter? It's a joke! Sooner Microsoft goes under and
becomes history the better. I have windows word processors, graphics
editors etc that are slower than the versions from 7 years ago. And my
computer/drives are 4 times faster. Doesn't this annoy anyone else?
-Roman

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


2000\10\05@105333 by Dan Michaels

flavicon
face
Roman Black wrote:
.......
Sooner Microsoft goes under and
>becomes history the better. I have windows word processors, graphics
>editors etc that are slower than the versions from 7 years ago. And my
>computer/drives are 4 times faster. Doesn't this annoy anyone else?


Ahhh, another potential convert for Linux. [you will be contacted
by the "Committee" anyday now - hush, hush].

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics


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