![]() | ![]() | ![]() |
| | |||||||
| Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution. |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) | ||
| Quote:
Quote:
| |||
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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 | |
| |
| | (permalink) | |
| Quote:
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. | ||
| |
| | (permalink) | |
| Quote:
| ||
| |
| | (permalink) |
| 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? | |
| |
| | (permalink) |
| Baudrate could be wrong at pc or pic side, data might be inverted... | |
| |
| | (permalink) |
| Your serout2 Code is incorrect. Code: DEFINE OSC 20 TRISA = %00000000 TRISB = %00000000 loop: SerOut2 PORTB.0,9600,["Hello",10,13] GoTo loop 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 | |
| |