Searching \ for '[PIC]:f877 UART' 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/devices.htm?key=877
Search entire site for: 'f877 UART'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]:f877 UART'
2003\02\27@121353 by Ian McLean

flavicon
face
I am hoping that someone can give me a definative answer on something which
has been puzzling me for a while.

I have found it difficult to get the f877 to transmit successfully through a
MAX232 chip without providing a 1k pull-up resistor on the PIC Tx line.
Whilst this is not mentioned in the datasheet, it was suggested to me by an
engineering friend.  I have followed this practise ever since on the PIC,
and it works every time.

Whilst this question is pretty much academic, is the pullup really
necessary, or should I be doing something different ?

Rgs
Ian.

--
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

2003\02\27@125032 by LARRY REYNOLDS

picon face
Ian,

       The PIC Demo ICD Board for the F87X series does not use any pull-ups
(or pull downs), when interfacing with the MAX232.  It does use some 330
ohm resistors in series, although I don't think they are needed.
Perhaps there is something else that bears looking into....

Larry


Ian McLean wrote:
>
<snip>...I have found it difficult to get the f877 to transmit
successfully through a MAX232 chip without providing a 1k pull-up
resistor on the PIC Tx line.

--
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

2003\02\27@130440 by Olin Lathrop

face picon face
> I have found it difficult to get the f877 to transmit successfully
> through a MAX232 chip without providing a 1k pull-up resistor on the
> PIC Tx line. Whilst this is not mentioned in the datasheet, it was
> suggested to me by an engineering friend.  I have followed this
> practise ever since on the PIC, and it works every time.
>
> Whilst this question is pretty much academic, is the pullup really
> necessary, or should I be doing something different ?

I you have something else wrong.  The PIC actively drives its TX line in
both directions, so no pullup is needed.  I've done quite a few PIC
projects with a MAX232A or equivalent connected directly to TX and RX
without any problems.  Are you sure the TRIS bits are set correctly?


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.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

2003\02\27@131053 by Charles Craft

picon face
If he's using the hardware USART on pin RC6 there's a blurb on page 99 of the datasheet about the pin going high impedance under certain circumstances.


--{Original Message removed}

2003\02\27@131939 by Ian McLean

flavicon
face
Olin, this is my initialisation code for Port C.  DO you see anything wrong
with it?

---------
InitC   movlw   b'01000000'     ; PORTC serial comm's, Timer0 ISR, Timer1 clock
input,
       movwf   PORTC           ; Timer2 PWM, & Go/Stop Button
       bsf     STATUS, RP0
       movlw   b'10000011'
       movwf   TRISC
       movlw   0x0C            ; 19200 baud
       movwf   SPBRG
       movlw   b'00100100'     ; brgh = high (2)
       movwf   TXSTA           ; enable Async Transmission, set brgh
       movlw   b'10010000'     ; enable Async Reception
       clrf    STATUS  ; RAM Page 0
       movwf   RCSTA
       clrf    dataL
Settle  decfsz  dataL, F
       goto    Settle
       call    FlushRxBuf      ; flush receive buffer
---------

Rgs
Ian.

{Original Message removed}

2003\02\27@133647 by Charles Craft

picon face
Page 95 of the datasheet says bits TRISC<7:6> have to be set.

Are you only setting bit 7?

--{Original Message removed}

2003\02\27@135526 by Ian McLean

flavicon
face
From the way I read it, TRIS<6> only needs to be set if you wish to enable
9bit transmission.  I did not think this was necessary for standard serial
comm's with a PC terminal application.  Am I wrong here in thinking 8bit
transmission is OK?  That is what I have set in the terminal application, 8
data bits.

Rgs
Ian.

{Original Message removed}

2003\02\27@140923 by Ian McLean

flavicon
face
Woops, sorry for the last reply, I screwed up there.  I was reading the
TXSTA register on page 95, not TRISC.  You are right, I am only setting
TRISC<7>, not TRISC<6>.  I will try this and remove the pullup.

But this confuses me.  Page 95 says set TRISC<6:7> for async serial comm's,
but I thought that because Tx was a transmit line, i.e. output, that Tx
(TRISC<6>) should be cleared.  Rx (TRISC<7>) set makes sense to me, but not
Tx.

So effectively, both Rx and Tx are set to inputs in the TRISC register?  How
strange.

RGs
Ian.

{Original Message removed}

2003\02\27@154139 by Jinx

face picon face
My setup for a working UART program - you have the data
directions for Rx and Tx transposed

;                  1          RS232 Receive, input
;                   0         RS232 Transmit, output
;                    0
;                     0       I2C SDA
;                      0      I2C SCL
;                       0
;                        0
;                         0

        bank1
        movlw   b'10000000'
        movwf   trisc

;================================================
;        Initialise RS232 serial comms
;================================================

; 19200 with BRGH = 1

; 19200 = 18.432MHz / (16 * (X+1))

; X = ( (18432000 / 19200) / 16 ) -1
; X = (960/16)-1
; X = 59

        movlw   .59          ;19200 baud @ 18.43200MHz
        movwf   spbrg
        movlw   b'00100100'  ;brgh=1, Asynch, 8-bit, Tx enabled
        movwf   txsta

        bank0
        movlw   b'10010000'  ;Asynch, 8-bit, Rx enabled
        movwf   rcsta
        movf    rcreg,w      ;clear receive buffer and rcif

=========================================================

> Olin, this is my initialisation code for Port C.  DO you see anything
wrong
> with it?
>
> InitC   movlw   b'01000000'     ; PORTC serial comm's, Timer0 ISR, Timer1
clock
{Quote hidden}

--
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

2003\02\27@154555 by Jinx

face picon face
> My setup for a working UART program - you have the data
> directions for Rx and Tx transposed

> > InitC   movlw   b'01000000'     ; PORTC serial comm
> >         movwf   PORTC           ; Timer2 PWM, & Go/Stop Button
> >         bsf     STATUS, RP0
> >         movlw   b'10000011'
> >         movwf   TRISC           ;<<<<<<< sorry, missed it

Ooopsie - didn't read far enough, my apologies. You ARE
setting Rx and Tx OK. I too have never used a pullup with
a MAX232

--
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

2003\02\27@164252 by Olin Lathrop

face picon face
> Olin, this is my initialisation code for Port C.  DO you see anything
> wrong with it?

Lack of documentation what the bit patterns mean for one.  You also assume
RP1 is set to 0, but this is not guaranteed by your code nor documented as
a requirement.

> InitC   movlw   b'01000000'     ; PORTC serial comm's, Timer0 ISR,
> Timer1 clock input,
>         movwf   PORTC           ; Timer2 PWM, & Go/Stop Button
>         bsf     STATUS, RP0
>         movlw   b'10000011'
>         movwf   TRISC

You forgot to set the TRIS bit for RC6.

{Quote hidden}

Take a look at my UART_BAUD and UART_SETUP macros in STD.INS.ASPIC at
http://www.embedinc.com.  You should also consider using something like my
/INBIT and /OUTBIT preprocessor directives.  That allows you to declare
each port in in the master include file, making a TRIS screwup much less
likely.  See my HOS project at http://www.embedinc.com/hos.htm for a
complete example project that uses the UART.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.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

2003\02\27@164515 by Olin Lathrop

face picon face
> Take a look at my UART_BAUD and UART_SETUP macros in STD.INS.ASPIC at
> http://www.embedinc.com.  You should also consider using something like
> my /INBIT and /OUTBIT preprocessor directives.  That allows you to
> declare each port in in the master include file, making a TRIS screwup
> much less likely.  See my HOS project at
> http://www.embedinc.com/hos.htm for a complete example project that
> uses the UART.

Sorry, both those URL's are wrong.  The first one should have been
http://www.embedinc.com/pic, and the second one
http://www.embedinc.com/pic/hos.htm.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.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

2003\02\27@165211 by Charles Craft

picon face
Figure 3-5 on page 33 of datasheet DS30292C shows that peripheral data does not go through the standard data latch.

So the statement (pg.95) about setting both bits to input makes sense.

And finally on page 99:

Clearing enable bit TXEN during a transmission will
cause the transmission to be aborted and will reset the
transmitter. As a result, the RC6/TX/CK pin will revert
to hi-impedance.





--{Original Message removed}

2003\02\27@175705 by David Duffy

flavicon
face
Charles wrote:
>Figure 3-5 on page 33 of datasheet DS30292C shows that peripheral data
>does not go through the standard data latch.
>
>So the statement (pg.95) about setting both bits to input makes sense.

I've always set (1) RX and cleared (0) TX and had no problems. I'd rather it
that way so the TX pin doesn't go hi-Z when you disable the transmitter &
leave the driver chip input floating about.
David...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
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

2003\02\27@184007 by Olin Lathrop

face picon face
> I've always set (1) RX and cleared (0) TX and had no problems. I'd
> rather it that way so the TX pin doesn't go hi-Z when you disable the
> transmitter & leave the driver chip input floating about.

You can "rather it that way" all you want, but that's just not how the
UART works.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.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

2003\02\27@191236 by David Duffy

flavicon
face
David wrote:
> > I've always set (1) RX and cleared (0) TX and had no problems. I'd
> > rather it that way so the TX pin doesn't go hi-Z when you disable the
> > transmitter & leave the driver chip input floating about.

Olin:
>You can "rather it that way" all you want, but that's just not how the
>UART works.

But that's the point - it is how it works.

<quote>
Clearing enable bit TXEN during a transmission will cause the
transmission to be aborted and will reset the transmitter.
As a result the RB2/TX/CK pin will revert to hi impedance.
</quote>

I don't want the TX pin to go into the hi-Z state when the transmitter
is disabled so I leave the tris bit for the TX cleared instead.
David...
___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
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

2003\02\27@193734 by Dwayne Reid

flavicon
face
At 06:37 PM 2/27/03 -0500, Olin Lathrop wrote:
> > I've always set (1) RX and cleared (0) TX and had no problems. I'd
> > rather it that way so the TX pin doesn't go hi-Z when you disable the
> > transmitter & leave the driver chip input floating about.
>
>You can "rather it that way" all you want, but that's just not how the
>UART works.

I can't answer to later PICs, but the 16c73b and 16c74b *do* work with
those TRIS bit settings.

dwayne

--
Dwayne Reid   <spam_OUTdwaynerTakeThisOuTspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
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

2003\02\27@194959 by David Duffy

flavicon
face
At 10:36 AM 28/02/2003, you wrote:
>At 06:37 PM 2/27/03 -0500, Olin Lathrop wrote:
>> > I've always set (1) RX and cleared (0) TX and had no problems. I'd
>> > rather it that way so the TX pin doesn't go hi-Z when you disable the
>> > transmitter & leave the driver chip input floating about.
>>
>>You can "rather it that way" all you want, but that's just not how the
>>UART works.
>
>I can't answer to later PICs, but the 16c73b and 16c74b *do* work with
>those TRIS bit settings.

The 16F876, 16F877, 16F628 all work with those settings too.
Maybe I'll be surprised (either way) when I get my 18F1220's. :-)
If I remember, I'll ask them at the Embedded Control Seminar.
David...
___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
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

2003\02\27@223655 by Ian McLean

flavicon
face
That is OK Jinx, I too have been guilty of jumping on posts without reading
thoroughly enough first ;)

Your settings for TRISC are the same as mine for TRISC<7:6> ???  This is
contrary to the datasheet on page 95, which states that Tx and Rx should
both be SET in TRISC, i.e.

InitC bsf STATUS, RP0
     movlw b'11000000'
     movwf     TRISC

This is what Charles and Olin were pointing out to me.

The reason that I am actually setting TRISC to b'100000011' is because I am
using PORTC<0:1> as inputs.  PORTC<0> is being used as a counter input to
Timer1, and PORTC<1> is being used as a button input.  If page 95 of the
datasheet is correct, then I should be setting TRISC to b'11000011'.

Quoting from page 95, "Bit SPEN (RCSTA<7>) and bits TRISC<7:6> have to be
set in order to configure pins RC6/TX/CK and RC7/RX/DT as the Universal
Synchronous Asynchronous Reciever Transmitter".

So Jinx, it looks like we are both in fact wrong.  Trouble is, I cannot
understand why firstly, it works for me with a 1k pullup on the (apparently
misconfigured) Tx line, and why it is working for you without.

Also, in every code example I have seen, it is set the same way that both
Jinx and I do it, not the way page 95 of the datasheet suggests.  Am I going
completely mad or what !?

It certainly makes a lot more sense to me (and apparently to you too Jinx)
to set Tx to an output.  "Transmit" means "output", right ? Jeez am I
confused now.

Olin or Charles, please, which way should it be ???  AN explanation would be
most appreciated.

Rgs
Ian.

{Original Message removed}

2003\02\27@225342 by Tony Nixon

flavicon
picon face
Ian McLean wrote:

> It certainly makes a lot more sense to me (and apparently to you too Jinx)
> to set Tx to an output.  "Transmit" means "output", right ? Jeez am I
> confused now.
>
> Olin or Charles, please, which way should it be ???  AN explanation would be
> most appreciated.


I personally set RC6 as HI/output and RC7 as input out of habit, but if
you look at the PORT diagram for PORTC, you will see that enabling the
USART overrides the settings of PORTC,6 PORTC,7 TRISC,6 and TRISC,7.
Therefore is doesn't matter what you write to these pins when the USART
is enabled because the data will simply not get there.

The only thing left to be wrong is with the code, the circuit layout,
the PIC or the MAX232, quite possibly in that order.

The RC6 TX pin has a push/pull output capable of around 20mA source/sink
so a pullup should not be required.

Frustrating I'll bet ;-)

--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
.....salesKILLspamspam@spam@bubblesoftonline.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

2003\02\27@232125 by Jinx

face picon face
Further to what Tony said, although I can't find an explicit mention
of it in a manual or AN, it appears SPEN configures Rx as i/p and
Tx as o/p in Asynch mode. All of my UART projects have been plain
Asynch PIC-PC comms so it's not something I've looked too far into,
especially with UART code as it is working satisfactorily

I presume that the Tx pin has bi-directional capabilities so it can
produce or accept CK in Synch mode

--
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

2003\02\27@232934 by Dwayne Reid

flavicon
face
At 02:52 PM 2/28/03 +1100, Tony Nixon wrote:
{Quote hidden}

I still think the answer has already been posted: according to the data
sheet section 10.2.1 (document DS30292C-page 99)

"Clearing enable bit TXEN during a transmission will cause the transmission
to be aborted and will reset the transmitter. As a result, the RC6/TX/CK
pin will revert to hi-impedance."

I think the problem is the high impedance state of pin RC6 while TXEN is
off.  Setting RC6 as HI / output fixes that problem.

dwayne

--
Dwayne Reid   <dwaynerspamKILLspamplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
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

2003\02\28@005216 by Charles Craft

picon face
Most of the serial code I have it bit banged.

Went back to some old code where I used the USART and found that I never initialized TRISC. The default power on value is all bits set to 1.

Without a circuit diagram or your code that does the serial comms we're all winging it. How about trying it with TRISC<7:6> set, with and without the resistor and report your results. :-)




--{Original Message removed}

2003\02\28@041530 by Alan B. Pearce

face picon face
>I don't want the TX pin to go into the hi-Z state when the transmitter
>is disabled so I leave the tris bit for the TX cleared instead.
>David...

But having set the UART up to use it, why would you then disable it?

If you have a requirement to disable it, surely that is the time to set the
RC6 bit to an output, and then in the next instruction disable the UART.
Otherwise while the UART is in normal operation you have two outputs trying
to drive the same line, and hence fighting each other.

Hope your not trying to use it like this in a low power application.

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\02\28@043423 by David Duffy

flavicon
face
David D wrote:
> >I don't want the TX pin to go into the hi-Z state when the transmitter
> >is disabled so I leave the tris bit for the TX cleared instead.

Alan P wrote:
>But having set the UART up to use it, why would you then disable it?
>
>If you have a requirement to disable it, surely that is the time to set the
>RC6 bit to an output, and then in the next instruction disable the UART.
>Otherwise while the UART is in normal operation you have two outputs trying
>to drive the same line, and hence fighting each other.

There's no fight or contention - the UART overrides the tris settings.
David...

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2003\02\28@072943 by Olin Lathrop
face picon face
> Olin or Charles, please, which way should it be ???

If the data sheet doesn't convince you, then all I can say is that I've
always set both TRIS bits and never had any problems.  I vaguely remember
a bug a few years ago with the UART on a 16C77 (?) where I didn't set both
TRIS bits correctly.  However, I'm not totally sure, and don't remember
the exact symptoms nor exactly what did done wrong.

Once I created the UART_BAUD macro and standard UART template module, I
haven't had a single problem.  I've recently added the UART_SETUP macro to
STD.INS.ASPIC at http://www.embedinc.com/pic.  This contains the assembly
time logic to handle the advanced UART of devices like the 18F1320.  I've
also added support for the much better baud rate generator of those
devices to UART_BAUD.  They finally gave it a full 16 bit counter so you
don't have to fart around with high/low speed baud rate generator mode
anymore.


*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.


'[PIC]:f877 UART'
2003\03\02@183933 by David Duffy
flavicon
face
> >I don't want the TX pin to go into the hi-Z state when the transmitter
> >is disabled so I leave the tris bit for the TX cleared instead.
> >David...

Alan wrote:
>But having set the UART up to use it, why would you then disable it?
>
>If you have a requirement to disable it, surely that is the time to set the
>RC6 bit to an output, and then in the next instruction disable the UART.
>Otherwise while the UART is in normal operation you have two outputs trying
>to drive the same line, and hence fighting each other.

Transmitting DMX (at 250kps) requires you to insert a timed break/make
into the serial stream at the start of each new packet. Leaving the TX pin
set to output and then turning the transmitter off/on was the quickest way
to achieve this.
David...

___________________________________________
David Duffy        Audio Visual Devices P/L
U8, 9-11 Trade St, Cleveland 4163 Australia
Ph: +61 7 38210362   Fax: +61 7 38210281
New Web: http://www.audiovisualdevices.com.au
___________________________________________

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu>

2003\03\03@080520 by Alan B. Pearce

face picon face
>Transmitting DMX (at 250kps) requires you to insert a timed break/make
>into the serial stream at the start of each new packet. Leaving the TX
>pin set to output and then turning the transmitter off/on was the
>quickest way to achieve this.
>David...

Fair enough, I just could not see a reasonable reason to do it.

It also just happens that I have a possible application coming up where I
may need to do something similar, so I guess I have learnt a technique
before I needed it.

Thanks
Alan.

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

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