• Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Circuit not working...

Status
Not open for further replies.

brentonw2004

New Member
Hello. I have been working on a car part that I was using a PIC 16F628 on, and Pic Basic Pro. I ended up needing an ADC so I switched to the 16F819. Now I cannot get my LCD or any serial communication to work. I think it is because of the timing. I tried to use the internal rc, but I could not get it to work. Now I am using a 20mhrz crystal and two 18pf capacitors. Here is how I have it set up:

pin 4 -> 2.2K -> 5v
pin 5 -> GND
pin 6 -> Serial port
pin 14 -> 5v
pin 15 -> 20mhrz -> 18pf -> GND
pin 16 -> 20mhrz -> 18pf -> GND

Here's my code:

DEFINE OSC 20

TRISA = %00000000
TRISB = %00000000

loop:

SerOut2 PORTB.0,9600,["Hello",10,13]

GoTo loop

I programmed it with a JDM programmer and ICPROG. I have tried pretty much every setting on the rc and haven't had any luck with any of them. Which one should you use? I am thinking HS, but I am not sure.


Also, this is a little off the subject, but how hard is it to get a 16f876 to work correctly. I have messed with the 819 for about two weeks and I am getting ready to give up on it. Is it easier to deal with?

One last question, does anyone have any advice on calibrating a pressure sensor and getting an actual reading out of it? Any advice on any of these would be greatly appreciated.

Thanks!
Brent
 

Nigel Goodwin

Super Moderator
Most Helpful Member
brentonw2004 said:
Which one should you use? I am thinking HS, but I am not sure.
For a 20MHz crystal you should use HS.

Also, this is a little off the subject, but how hard is it to get a 16f876 to work correctly. I have messed with the 819 for about two weeks and I am getting ready to give up on it. Is it easier to deal with?
It's easy to get a 16F876 to work, but it 'should' be easy to get an 819 to work as well. I'm presuming your PicBasic Pro supports the 819?.
 

brentonw2004

New Member
On there website it said that my version of pic basic pro supports it. It has all of the includes. I think that it is only my timing slightly off, because the only thing that I notice is corrupt is serial communication. I have also read that serial communiction will not work unless it is almost exactly perfect. Are my crystals right? Does the internal rc have anything to do with why it's not working? Is 18pf correct? I have read some places that you use 15pf and other places say that you use 18pf? How big of a difference would this make?

Thanks!!
Brent
 

Exo

Active Member
How is the pic connected to the serial port of the pc? You need an inverter between pic and pc. Or a RS232 driver like a MAX232
 

brentonw2004

New Member
I am just connecting pin 2 of a serial cable to my pic and pin 5 to ground. Then I just plug it into my com1 port on the back or my computer and watch for the signal in HyperTerminal. I have did it like this before and everything worked fine on the 16f628. Does anyone have any advice?

Thanks!
Brent
 

Nigel Goodwin

Super Moderator
Most Helpful Member
brentonw2004 said:
On there website it said that my version of pic basic pro supports it. It has all of the includes. I think that it is only my timing slightly off, because the only thing that I notice is corrupt is serial communication. I have also read that serial communiction will not work unless it is almost exactly perfect. Are my crystals right? Does the internal rc have anything to do with why it's not working? Is 18pf correct? I have read some places that you use 15pf and other places say that you use 18pf? How big of a difference would this make?

Thanks!!
Brent
The value of the caps seems to make very little difference - I use whatever I happen to have to hand, anywhere from 10pF to 27pF, as long as they are both the same.

Are you sure the configuration fuses are set correctly?, read the chip back and check what they are set to - if you have a 20MHz crystal, but the chip is set to use the internal oscillator - it will only be running at 4MHz.

Using the in-built RC oscillator at 4MHz on a 16F628 works fine for serial comms, using either software or the hardware USART - I've no reason to suspect an 819 would be any different, and running it from a crystal it's going to be more than accurate enough.
 

Nigel Goodwin

Super Moderator
Most Helpful Member
brentonw2004 said:
I am just connecting pin 2 of a serial cable to my pic and pin 5 to ground. Then I just plug it into my com1 port on the back or my computer and watch for the signal in HyperTerminal. I have did it like this before and everything worked fine on the 16f628. Does anyone have any advice?
RS232 on a PIC is 'usually' intended for use with a MAX232, which inverts the signal - using the hardware USART, you have to do so to get the polarity correct. If using software simulation for RS232, you can invert it in software if you like - but you need to have it set correctly for what you are wanting to do - presumably your compiler will explain what you need to do, and how you do it.
 

brentonw2004

New Member
I finally got it sort of working. I finally got it to send some data to the computer, but it is wrong. Instead of the computer reading 'Hello', I am getting " !ëåo5'' " I have tried to use SerOut and SerOut2, but they are both messing up. Any advice on this?
 

ivancho

New Member
Your serout2 Code is incorrect.
Code:
DEFINE OSC 20 

TRISA = %00000000 
TRISB = %00000000 

loop: 

SerOut2 PORTB.0,9600,["Hello",10,13] 

GoTo loop
The part where it says 9600 for the baudrate is actually giving you a baudrate of 103.95. And that explains the error.
Since you have your PIC connected straight to the serial port then you are going to need to send the data inverted, and if you want to use a 9600 baud rate then you will need to change your Serout2 command to:

Code:
SerOut2 PORTB.0,16468,["Hello",10,13]

Ivancho
 
Status
Not open for further replies.

Latest threads

EE World Online Articles

Loading
Top