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.

Need help with pic16f819

Status
Not open for further replies.

kaos

New Member
Hello i am doing a project for school and PIC programming using the PIC16f819 our teacher has no clue on how the chip works and we have been emailing tech support with only limited help from them.
Anyways this is basically what I want to do

Make a led blink at regular intervals
I have the wiring as
MCLR going to 1 k resistor goiing to +5
RAO going to a 100 ohm resistor going to led going to ground
+5 volts on VDD
ground to VSS

Is this a good wiring (teacher gave this to us) we just need help with the programming
We are using the Pic basic pro compiler.
Thanks

Also i have looked at the data sheets but i am not getting much from it
although i will keep looking at it.
 
Personally, I prefer a 3.9k resistor from MCLR to 5 volts.

as far as the code goes, using porta.0 with a 1k resistor and LED to ground


INCLUDE# "modedefs.bas"
blink:
high porta.0
pause 500
low porta.0
pause 500
goto blink
 
thanks a lot i will give this a try in class tomorrow. I was wondering dont u need to use the adcon0 or adcon1 ? Also i tried using some code and the led would blink but it was totally random (even though the pause was for 500 ms) was wondering if this was an osciallator problem?
Anyways ill try this code tommorow and post my results.
How much of a difference would there be if i changed the 1k to a 3.9k Just less power going to resistor (remeber i am new to this) and would the code need to be changed at all.
Thanks for your help!
 
Yeah i tried that code and i still cant get it to work
Do u need to do adcon0 to anything cause i tried adcon0=%10001111 and i tried without o no success. Sometimes the LED blinks randomly and other times u need to touch the resistor for it to turn on any suggestions?
 
ADCON0 shouldn't matter, you want to set the ports up to be digital.

so...

ADCON1 = 00000111

(or you could use a non-analog capable I/O pin)

What are you using for your clock?
 
I am new to this so i am not sure what u mean by the clock. Like i said its wierd the light will either flash at random intervals or by touching the resistor the led will go on for a second or so. (And i tried it on several different boards with several different chips so i know its not a loose connection)
 
The clock would be something like an external crystal to set the speed the PIC will run at. The PIC you are using has an internal clock you can use, it does have to be told to use it however. Usually this is set when you program the PIC. Check the settings you are using with your device programmer software and make sure you have selected the internal clock.
 
well the compiler has 2 options IntrC (int) and intrc clockout
it was set to the intrC (int) no such luck
 
Your clock setting sounds right. What are you using for a 5 volt power supply? If it's noisy it could be causing the problem. Try a 10uF cap across the power supply pins.

What was your teacher thinking when he assigned this project?
He really is supposed to know what he's doing, good luck.
 
we are using direct current from the bench. The benchies power workes fine but what we have noticed from the bench is that the current is extremly low (light still turns on but current is low) was wondering if that would cause iti havent tried using battiries yet maybe i should

I am not sure what are teacher was thinking. Right now he says he isnt marking whether we get it working or not (if we do we get 100%) he is marking the process of what we are doing to try to get it to work so basically i am getting some marks for just posting here and u replying back.

This is really ticking me off since it is a kinda new chip there isnt much support out there heck you are the only person that responsded (i tried posting at other forums no luck)

Its very wierd because when anything touches the resistor going to the led the led will go on for a random amount of time then turn off.
The only thing left i can think off is trying another power source as u mentioned. I tried different resistors different chips different led different bench power different bread boards different programs only think i didnt try was a different kind of power. I wouldnt be suprised if there was noise from the power considering 11 other benches share the power.
Will try tommorow
 
If your power is no good then the PIC is not going to work. Try a 9V battery and a 7805 voltage regulator for power. 4.5V worth of C or D batteries may work also.

You could also try setting port a to all outputs TRISA = 0This should be done automatically by the HIGH command, but it's worth a shot.

The internal oscillator control register may also need to be set. I don't know what it defaults to, but try OSCCON = %01000100. Your editor will need to support the PIC you are using for this to work. Mine doesn't so I haven't been able to try it.

See if your teacher will let you use a different PIC. The 16F628 also has an internal oscillator and is much easier to use. The 16F84 is the old standby for hobbiests, but requires a crystal oscillator(no big deal, just a crystal and 2 22pF caps)
 
Thanks for all the help you have given me, its gotten me a lot closer for it to work then what i was before.
I will ttry the stuff you mentioned in the last post and see if it works.
If it doesnt work I give up if it does work YAHOOOOOOOOOOOOOOOOo i get 100% on that part of the project (and all thanks goes to you)
The teacher wont be getting any other chips because there is only a week left of school and he wouldnt be able to get the parts in time.


I will post my results in a few hours.
 
WELL I TRied it all and no luick when i used the 9V battery weith the 5 volt 7805 voltage regulator i wasnt getting anything at all.
well i officially give up as i have ran out of ideas. at least ill get the best mark on it for getting the closest and working the hardest on it.

Thanks for all of your help you have helped me alot.
Kaos
 
its quite possible u nerf'd the PIC
they have a maximum source of 25ma a 100ohm resistor the the LED odds are would exceed that if the LED had a "normal" style 0.7 voltage drop. First principles OHMS law can save u from that smell of burnt plastic!

also 1k for an LED seams way out and would make it VERY dim.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top