UART and PIC16f877a

S

sandeepa

Guest
I am trying to send characters to the PC using the hardware UART in
16f877a.
The problem is that the characters are displayed only after I switch
off the power to the PIC.I have tried various snippets of codes used
successfully by others,however the result is always the same.
I am using MAX232 between the PC and the PIC.
Also when I tried receiving a character and transmitting it
again,nothing happened.i.e. even after powering down the PIC,nothing
was displayed as was the case previously.
Shorting the Tx and Rx pins however displays the keyed in character on
the screen.
What could be going wrong?
Thanks.
 
sandeepa wrote:
I am trying to send characters to the PC using the hardware UART in
16f877a.
The problem is that the characters are displayed only after I switch
off the power to the PIC.I have tried various snippets of codes used
successfully by others,however the result is always the same.
I am using MAX232 between the PC and the PIC.
Also when I tried receiving a character and transmitting it
again,nothing happened.i.e. even after powering down the PIC,nothing
was displayed as was the case previously.
Shorting the Tx and Rx pins however displays the keyed in character on
the screen.
What could be going wrong?
Thanks.
I'm betting the problem is in the PC setup. Hook two PCs together, get
them talking, then try the PIC.
mike

--
Return address is VALID but some sites block emails
with links. Delete this sig when replying.
..
Wanted, PCMCIA SCSI Card for HP m820 CDRW.
FS 500MHz Tek DSOscilloscope TDS540 Make Offer
Wanted, 12.1" LCD for Gateway Solo 5300. Samsung LT121SU-121
Bunch of stuff For Sale and Wanted at the link below.
MAKE THE OBVIOUS CHANGES TO THE LINK
ht<removethis>tp://www.geocities.com/SiliconValley/Monitor/4710/
 
"sandeepa" <sandy261180@gmail.com> wrote in message
news:1111418677.976972.155850@f14g2000cwb.googlegroups.com...
I am trying to send characters to the PC using the hardware UART in
16f877a.
I've done the same thing, and have seen it work.

The problem is that the characters are displayed only after I switch
off the power to the PIC.I have tried various snippets of codes used
successfully by others,however the result is always the same.
I am using MAX232 between the PC and the PIC.
Also when I tried receiving a character and transmitting it
again,nothing happened.i.e. even after powering down the PIC,nothing
was displayed as was the case previously.
Shorting the Tx and Rx pins however displays the keyed in character on
the screen.
What could be going wrong?
I suspect that Mr. Luhan has got the gist of it.
If you use Hyperterminal, and defeat enough
handshaking in its options dialog(s), (assuming
your PIC is not handshaking as you would
surely have stated if so), then you may well
see the characters as soon as they are sent.

Thanks.
You are welcome.

--
--Larry Brasfield
email: donotspam_larry_brasfield@hotmail.com
Above views may belong only to me.
 
loop
clrf STATUS

serial_transmit:
banksel PIR1
btfss PIR1,TXIF
goto serial_transmit
clrf STATUS
movlw 'h'
movwf TXREG
call transmit_wait
movlw 'e'
movwf TXREG
call transmit_wait
movlw 'l'
movwf TXREG
call transmit_wait
movlw 'l'
movwf TXREG
call transmit_wait
movlw 'o'
movwf TXREG
call transmit_wait
movlw .13; Carriage return
movwf TXREG
call transmit_wait
movlw .10; Linefeed
movwf TXREG
call transmit_wait
goto loop

transmit_wait
banksel TXSTA
btfss TXSTA,TRMT
goto transmit_wait
clrf STATUS
return

The output seen is
hello
h

after I switch the PIC off.

Dont have a scope;so cant see the waveforms on the pins.
I am not using any handshaking signals.Have tried both ways;with just 3
pins(Tx,Rx,Gnd) as well as the others connected ina way to make it look
like the handshaking signals were present.The result in both the cases
is the same.

Also, since I had read that Hyperterminal causes problems,got the Tera
Term software,the same thing happens with it as well.

Just cant figure out whats happening...please help.

Thanks.
 
On 21 Mar 2005 22:53:28 -0800, "sandeepa" <sandy261180@gmail.com> wrote:

The output seen is
hello
h

after I switch the PIC off.

Dont have a scope;so cant see the waveforms on the pins.
I am not using any handshaking signals.Have tried both ways;with just 3
pins(Tx,Rx,Gnd) as well as the others connected ina way to make it look
like the handshaking signals were present.The result in both the cases
is the same.

Also, since I had read that Hyperterminal causes problems,got the Tera
Term software,the same thing happens with it as well.

Just cant figure out whats happening...please help.

Thanks.
Nothing is displayed until you turn off the PIC? If so, that's wierd.

What you show as output amounts to 8 bytes. Not sure if that means
anything. The PIC doesn't have an 8-byte buffer in its serial TX path
but the receive end could.

You need a way to gather more info. You say you don't have a scope. I'd
attach an LED to a pin on the PIC and write some code that can toggle it
with a half second delay or thereabouts. First just get the LED toggling
working. Now put that code at the end of your tx loop. If your LED keeps
flashing and you got some data on the receiving end, then it is probably
still sending. Simplify, checkpoint, rule things out, insert and move
debugging code.

You should really find some way to see if the serial interface is
toggling. There are cheap logic probes that could help or think of
another way.

You need to find ways to gather more information, otherwise you are just
making laps around the elephant. (The three blind men story. An elephant
looks like a tree, no, it looks like...)
 
I`ve had this problem.
With the pic 16f877 i think you can invert the polatiy of the uart signal as
the max232 contains an inverter, so the signal is inverted.

I think this was the soloution, it was a long time ago i had that problem.

Thanks
 
SNIP
I suspect that Mr. Luhan has got the gist of it.
If you use Hyperterminal, and defeat enough
handshaking in its options dialog(s), (assuming
your PIC is not handshaking as you would
surely have stated if so), then you may well
see the characters as soon as they are sent.
Try to get the ancient Terminal.exe (e.g. from windows 3.x) It is
considerable less temperamentel than Hyperterminal.

Wim
 
In article <423fceaa$0$81033$ed2e19e4@ptn-nntp-reader04.plus.net>,
timmmmayyy@nospamplease.com says...
I`ve had this problem.
With the pic 16f877 i think you can invert the polatiy of the uart signal as
the max232 contains an inverter, so the signal is inverted.

I think this was the soloution, it was a long time ago i had that problem.

Thanks

Nope, the level shifter does do an invert, sort of, a 1 becomes a
negative voltage and a 0 becomes a positive voltage, BUT all of that
gets converted back to the appropriate values when the other ends level
shifter does its thing. I believe you are remembering what you had to
do if you wanted to use the UART with out a level shifter. There is a
little resistor trick you can do to get a PIC to do half asses rs-232
with out the level shifter.

Jim
 
On Tue, 22 Mar 2005 15:08:15 +0000, Wim Ton wrote:

SNIP
I suspect that Mr. Luhan has got the gist of it.
If you use Hyperterminal, and defeat enough
handshaking in its options dialog(s), (assuming
your PIC is not handshaking as you would
surely have stated if so), then you may well
see the characters as soon as they are sent.

Try to get the ancient Terminal.exe (e.g. from windows 3.x) It is
considerable less temperamentel than Hyperterminal.
Heck, if you're going for a dumb terminal, try Telix or Procomm
or Kermit, if you can still find any of them.

Good Luck!
Rich
 
On Tue, 22 Mar 2005 17:59:32 GMT, Rich Grise <richgrise@example.net>
wrote:

On Tue, 22 Mar 2005 15:08:15 +0000, Wim Ton wrote:

SNIP
I suspect that Mr. Luhan has got the gist of it.
If you use Hyperterminal, and defeat enough
handshaking in its options dialog(s), (assuming
your PIC is not handshaking as you would
surely have stated if so), then you may well
see the characters as soon as they are sent.

Try to get the ancient Terminal.exe (e.g. from windows 3.x) It is
considerable less temperamentel than Hyperterminal.


Heck, if you're going for a dumb terminal, try Telix or Procomm
or Kermit, if you can still find any of them.

Good Luck!
Rich
Last year I was looking for a simple terminal program that had an option
to display or send in hex. I found this one...
http://www.rolf-schroedter.de/moni/moni.html

Its freeware too.
 
Hello everyone,
Thanks for all your inputs.Last night got the thing working.
My mistake all along(as is always the case) ...

The configuration word had been accidently set to 3F7A instead of
0x3F7A!!!

Tried all the codes I had tried before and they all work fine.

A missing "0x" and two days of complete frustration.

Though still dont know what it would have actually meant,because I have
read that numbers without any explicit base are taken as the default
which is hex anyway.
But changing that and absolutely nothing else has got the thing
wprking.

Thank you all for all your help once again.
 
On Tue, 22 Mar 2005 19:18:08 GMT, xray <notreally@hotmail.invalid>
wrote:

On Tue, 22 Mar 2005 17:59:32 GMT, Rich Grise <richgrise@example.net
wrote:

On Tue, 22 Mar 2005 15:08:15 +0000, Wim Ton wrote:

SNIP
I suspect that Mr. Luhan has got the gist of it.
If you use Hyperterminal, and defeat enough
handshaking in its options dialog(s), (assuming
your PIC is not handshaking as you would
surely have stated if so), then you may well
see the characters as soon as they are sent.

Try to get the ancient Terminal.exe (e.g. from windows 3.x) It is
considerable less temperamentel than Hyperterminal.


Heck, if you're going for a dumb terminal, try Telix or Procomm
or Kermit, if you can still find any of them.

Good Luck!
Rich


Last year I was looking for a simple terminal program that had an option
to display or send in hex. I found this one...
http://www.rolf-schroedter.de/moni/moni.html

Its freeware too.
Have a look at Bray Terminal:
http://bray.velenje.cx/avr/terminal/
also free!!

Alan


--
++++++++++++++++++++++++++++++++++++++++++
Jenal Communications
Manufacturers and Suppliers of HF Selcall
P O Box 1108, Morley, WA, 6943
Tel: +61 8 9370 5533 Fax +61 8 9467 6146
Web Site: http://www.jenal.com
Contact: http://www.jenal.com/?p=1
++++++++++++++++++++++++++++++++++++++++++
 
Just a update,because things are I think now making some sense.
I tried the code that worked yesterday with __config 3F7A,i.e. without
the 0x.
And it still worked....and I almost got spooked out.

So went back to my first code .The config value set there is 3F79,which
sets the oscillator to XT.(3F7A sets it to HS).Burned it on the
chip(i.e. config set to 3F79),and things started behaving as before
i.e. display after power switched off.Changed the setting to 3F7A and
all was fine again.

So the mistake really was not,not specifying the base(which makes no
difference),but setting the wrong oscillator bits.(I need to set it to
HS as I am using 8MHz crystal).

JUst thought I should put in the final update here.
Thanks.
 
On Tue, 22 Mar 2005 17:59:32 +0000, Rich Grise wrote:

Heck, if you're going for a dumb terminal, try Telix or Procomm
or Kermit, if you can still find any of them.
Kermit is still alive and kicking.

--
"Electricity is of two kinds, positive and negative. The difference
is, I presume, that one comes a little more expensive, but is more
durable; the other is a cheaper thing, but the moths get into it."
(Stephen Leacock)
 

Welcome to EDABoard.com

Sponsor

Back
Top