Continue to Site

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.

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

Problems with PIC16F819

Status
Not open for further replies.

brentonw2004

New Member
Hello again everyone. I have a PIC 16F819 and I am having difficulties getting started with this chip. I have worked with some more basic PICs before, but I needed the ADC of the 16F819. I have it hooked up as follows:

Pin4 -> 2.7K -> +5V
Pin5 -> GND
Pin7 -> LED -> GND
Pin14 -> +5V

Here's my very simple Pic Basic Pro code:

loop:
HIGH PORTB.1
PAUSE 500
LOW PORTB.1
PAUSE 500
GOTO loop

My first problem with this is that I am getting basically random signals from all of the other pins, some are high and some are low whenever I haven't told any but PORTB.1 to do anything. It took me a while to realize, but the code actually is working, but the timing is very slow. It takes roughly a minute for the LED to change to high or low when it should only take half a second. I am guessing that there is an internal clock that has something to do with this. How do you set the internal clock? Do I have to use an external crystal? On the 16F628 I just hooked it up this same way and it worked fine. My last problem, is that I tried to hook it up to a serial cable and send data to my computer using SEROUT, but it wouldn't do anything. I am guessing that this is also because of the timing in the chip. Does the microchip have to have a USART to communicate serially? Any advice at all would be greatly appreciated.

Thanks!
Brent
 
The 16F819 has a number of internal oscillators available, I think they are 32KHz, 4MHz, and 8MHz. It's all explained in the datasheet, including how you set it to use which you want.
 
One of the problems with the datasheet is that I am using Pic Basic instead of assembly, which I am clueless about. Another thing is that I may have already erased the OSCCAL value by programming it already. How do you even set an OSCCAL on the 16F819? I tried just OSCCAL = $00 in code designer, and it didn't recognize OSCCAL. Would an external crystal override the internal one? Thanks for your help!
Brent
 
brentonw2004 said:
One of the problems with the datasheet is that I am using Pic Basic instead of assembly, which I am clueless about. Another thing is that I may have already erased the OSCCAL value by programming it already. How do you even set an OSCCAL on the 16F819? I tried just OSCCAL = $00 in code designer, and it didn't recognize OSCCAL. Would an external crystal override the internal one? Thanks for your help!
Brent

I don't use PIC Basic, so I can't comment on it, but if it supports the 16F819 presumably the instructions will give you all the information you need.

To select internal or external oscillator requires changes to the config fuses, this can either be done within the programmer software, or assembled into the HEX file - again, from PIC Basic, it should be explained how to do it in the instructions.

If you've overwritten the OSCCAL value, the internal oscillator won't be running accurately - however, any programmer suitable for the 16F819 'should' read the OSCCAL value and restore it automatically, this is part of the MicroChip programming specification.

The OSCCAL value is stored in the byte at the very top of program memory, try reading the PIC and checking what's there.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top