[PIC] Possible bug in the PIC16F648A USART

29 views
Skip to first unread message

Isaac Marino Bavaresco

unread,
Jun 21, 2010, 4:27:57 PM6/21/10
to Microcontroller discussion list - Public.
I was getting really weird behavior from a PIC16F648A:

The serial data out was available at both RX (RB1) and TX (RB2) pins.
At first I suspected that both pins could be shorted together outside of
the chip, then I noticed that the RX pin signal was inverted.
Very odd, because I don't have any inverter on the board, not even a
transistor.

After too much fuss (even cutting tracks and removing components), I
found that I had the RX and TX pin directions reverted (TRISB register).
Then I corrected the pin directions and everything worked OK. It is
worthy noticing that bit CREN at RCSTA was turned off also.


I will restore the wrong code to confirm it all, but it is a very odd
behavior indeed, RX outputting the inverted signal when configured as
output.


Isaac

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/

--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

Dario Greggio

unread,
Jun 21, 2010, 4:36:43 PM6/21/10
to Microcontroller discussion list - Public.
Isaac Marino Bavaresco ha scritto:

> I was getting really weird behavior from a PIC16F648A:
>
> The serial data out was available at both RX (RB1) and TX (RB2) pins.
> At first I suspected that both pins could be shorted together outside of
> the chip, then I noticed that the RX pin signal was inverted.
> Very odd, because I don't have any inverter on the board, not even a
> transistor.


nice one...
I'm using them and their USART and it's all ok.

David

unread,
Jun 21, 2010, 6:21:18 PM6/21/10
to Microcontroller discussion list - Public.
On 21/06/2010 21:27, Isaac Marino Bavaresco wrote:
> I was getting really weird behavior from a PIC16F648A:
>
> The serial data out was available at both RX (RB1) and TX (RB2) pins.
> At first I suspected that both pins could be shorted together outside of
> the chip, then I noticed that the RX pin signal was inverted.
> Very odd, because I don't have any inverter on the board, not even a
> transistor.
>
> After too much fuss (even cutting tracks and removing components), I
> found that I had the RX and TX pin directions reverted (TRISB register).
> Then I corrected the pin directions and everything worked OK. It is
> worthy noticing that bit CREN at RCSTA was turned off also.

I would be interested to know what values you ended up with for TRISB1
and TRISB2. The following comment is taken straight from the datasheet,
page 80:

"TRISB<1> and TRISB<2> should both be set to
‘1’ to configure the RB1/RX/DT and RB2/TX/CK
pins as inputs. Output drive, when required, is
controlled by the peripheral circuitry."

I noticed this for the first time yesterday when setting up USART on an
18F, but it appears to be the same for the 16F648A too.

Perhaps this is related to the problem you are having and maybe
following that advice would be the best.

David

ivp

unread,
Jun 21, 2010, 7:12:21 PM6/21/10
to Microcontroller discussion list - Public.
> the chip, then I noticed that the RX pin signal was inverted.
> Very odd, because I don't have any inverter on the board, not
> even a transistor

I wonder, because Rx is hi-Z, if it might be some sort of reflected
signal, or a r-m-w effect. I've seen similar behaviour with other
signals when an input is next to an output or a shadow register
not used

> "TRISB<1> and TRISB<2> should both be set to
> ‘1’ to configure the RB1/RX/DT and RB2/TX/CK
> pins as inputs. Output drive, when required, is
> controlled by the peripheral circuitry."

This is the datasheet advice for many PICs and their other
comms modules

RussellMc

unread,
Jun 22, 2010, 3:30:35 AM6/22/10
to Microcontroller discussion list - Public.
> I was getting really weird behavior from a PIC16F648A:

What are you connecting the RX/TX signals to?
Is there ANY chance that the PIC body diodes are being driven into conduction.
That can account for just about any behavior - a mere inversion of the
TX pins should be easy :-.

           Russell

Isaac Marino Bavaresco

unread,
Jun 22, 2010, 9:43:14 AM6/22/10
to Microcontroller discussion list - Public.
Em 21/6/2010 17:36, Dario Greggio escreveu:
> Isaac Marino Bavaresco ha scritto:
>
>> I was getting really weird behavior from a PIC16F648A:
>>
>> The serial data out was available at both RX (RB1) and TX (RB2) pins.
>> At first I suspected that both pins could be shorted together outside of
>> the chip, then I noticed that the RX pin signal was inverted.
>> Very odd, because I don't have any inverter on the board, not even a
>> transistor.
>>
>
> nice one...
> I'm using them and their USART and it's all ok.
>


They work OK. You snipped the rest of my message where I tell what I was
doing wrong.
I was just pointing out the odd and unexpected behavior when not
correctly configured.


Isaac

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/

--

Isaac Marino Bavaresco

unread,
Jun 22, 2010, 9:56:38 AM6/22/10
to Microcontroller discussion list - Public.
Em 22/6/2010 04:30, RussellMc escreveu:
>> I was getting really weird behavior from a PIC16F648A:
>>
> What are you connecting the RX/TX signals to?
> Is there ANY chance that the PIC body diodes are being driven into conduction.
> That can account for just about any behavior - a mere inversion of the
> TX pins should be easy :-.
>
>
>
> Russell
>


The subject of my message was misleading.

It was all about a mistake in my configuration of the serial port. I was
just pointing that the serial port exhibited a weird and unexpected
behavior *when ill configured*.


Isaac

__________________________________________________
Fale com seus amigos de graça com o novo Yahoo! Messenger
http://br.messenger.yahoo.com/

--

RussellMc

unread,
Jun 22, 2010, 10:04:57 AM6/22/10
to Microcontroller discussion list - Public.
> The subject of my message was misleading.

Yes.
Your post made sense but, even though I read it all and essentially
understood it one of the "little men" inside my head who runs around
answering questions saw the heading and was compelled to answer the
query :-). The one who noticed that the text proposed and solved its
own problem neglected to pass the information on.

> It was all about a mistake in my configuration of the serial port. I was
> just pointing that the serial port exhibited a weird and unexpected
> behavior *when ill configured*.

Yes. Something like that would have been a better subject line - but
all good fun.

R

Reply all
Reply to author
Forward
0 new messages