Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 15th June 2008, 06:59 PM   (permalink)
Default

When i build this program it built successfully. Then, i programmed it into a 16F84a but when i place an led in RB0 with correct resistor nothing happen!

I am trouble shooting my circuit

Q>how i know if the crystal i bought 4MHz is working or not?
__________________
Hesham Ismail Mohammed Sharif
Thank me if you want

Last edited by uaefame; 15th June 2008 at 06:59 PM.
uaefame is offline  
Old 15th June 2008, 10:34 PM   (permalink)
Default

Quote:
Originally Posted by uaefame View Post
Q>how i know if the crystal i bought 4MHz is working or not?
It would appear that you have the wrong oscillator type selected in your __CONFIG line. A 4MHz crystal should have XT selected, not LP. Your config line
Code:
	__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _LP_OSC
should read:
Code:
	__CONFIG _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC
The program can't get much simpler. If the LED is wired correctly, the MCU has 5V power and ground connected and your MCLR pin is pulled high with a 10K to 33K resistor then it has to work.

Here's a basic 16F84 breadboard you can have a look at to compare with how yours is set up.

Your crystal needs two (typically) 22pF loading capacitors to work properly. Wire them like this (not a 16F84, but same idea):
bleh.jpg
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 15th June 2008, 11:03 PM   (permalink)
Default

I change the codes you suggested still not working.

I will post the schematic that i am following
Attached Images
File Type: jpg LEDwith16F84a.JPG (82.8 KB, 10 views)
__________________
Hesham Ismail Mohammed Sharif
Thank me if you want
uaefame is offline  
Old 15th June 2008, 11:43 PM   (permalink)
Default

Quote:
Originally Posted by uaefame View Post
I will post the schematic that i am following
There's the problem. Like I said previously, MCLR must be pulled high with a resistor. Your schematic shows it pulled low. When MCLR is held low the PIC is in RESET, and halted. No program runs with MCLR pulled low like that.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 15th June 2008 at 11:47 PM.
futz is offline  
Old 16th June 2008, 12:51 AM   (permalink)
Default

Q> What you mean by pulled high and pulled low and when do i use pulled high or pulled low?
__________________
Hesham Ismail Mohammed Sharif
Thank me if you want
uaefame is offline  
Old 16th June 2008, 01:26 AM   (permalink)
Default

Wow it worked i connected MCLR to 5V and it worked i guess that was the problem.
Thanks futz for giving me guide
__________________
Hesham Ismail Mohammed Sharif
Thank me if you want
uaefame is offline  
Old 16th June 2008, 01:35 AM   (permalink)
Default

A pull up or pull down resistor is used to create a default value or state for a signal. Now you have MCLR wired to +5V. If you connect an ICSP it will not work because the signal is stuck at +5V. If you were to put a 10K or 20K resistor between MCLR and +5V then MCLR would be +5V when no other signal was present. But because of the resistor a signal from an ICSP connector could change the value to VPP or GND as needed.

A pull down works the same way but the default become GND.

Most often the an input will have a pullup or pulldown and one or more other signals that will be tristated (turned off or made an input) when not in use.

HTH

Last edited by 3v0; 16th June 2008 at 01:37 AM.
3v0 is offline  
Old 16th June 2008, 03:09 AM   (permalink)
Default

Quote:
Originally Posted by uaefame View Post
Q> What you mean by pulled high and pulled low and when do i use pulled high or pulled low?
In case you didn't understand 3v0's pullup/pulldown explanation I found another good explanation on the interweb.

And, like 3v0 says, don't connect MCLR directly to VDD. Use a pullup resistor between the MCLR pin and VDD. 22K or 33K are good, but it isn't critical. Anything from 10K to 33K is fine.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 16th June 2008, 09:04 AM   (permalink)
Default

Quote:
Originally Posted by futz View Post
And, like 3v0 says, don't connect MCLR directly to VDD. Use a pullup resistor between the MCLR pin and VDD.
This is really just personal choice, PIC's are designed for a direct MCLR connection if you wish, but obviously it prevents ICSP - if you don't use ICSP, then you don't need a resistor - if you do use ICSP, then you need a resistor and a diode.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 16th June 2008, 09:47 AM   (permalink)
Default

Quote:
Originally Posted by Nigel Goodwin View Post
This is really just personal choice, PIC's are designed for a direct MCLR connection if you wish, but obviously it prevents ICSP - if you don't use ICSP, then you don't need a resistor - if you do use ICSP, then you need a resistor and a diode.
I was under this assumption as well but it seems that later pics shouldn't have MCLR connected direct to Vdd.

From the 16F876A data sheet,
Quote:
The behavior of the ESD protection on the MCLR pin
differs from previous devices of this family. Voltages
applied to the pin that exceed its specification can
result in both Resets and current consumption outside
of device specification during the Reset event. For this
reason, Microchip recommends that the MCLR pin no
longer be tied directly to VDD. The use of an RCR
network, as shown in Figure 14-5, is suggested.
Mike.
Pommie is offline  
Old 17th June 2008, 06:31 AM   (permalink)
Default

Sorry for my basic question

Q> what is ICSP?
__________________
Hesham Ismail Mohammed Sharif
Thank me if you want
uaefame is offline  
Old 17th June 2008, 06:56 AM   (permalink)
Default

Quote:
Originally Posted by uaefame View Post
Sorry for my basic question

Q> what is ICSP?
In Circuit Serial Programming

Means that you connect a 5-wire cable to the target circuit to reprogram it in place, rather than pry the PIC out and take the chip to the programmer.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 17th June 2008, 10:26 PM   (permalink)
Default

Quote:
Originally Posted by Pommie View Post
I was under this assumption as well but it seems that later pics shouldn't have MCLR connected direct to Vdd.

From the 16F876A data sheet,


Mike.

Figure 14-5 in the datasheet gives an upper bound for the value for one of the resistors and a lower bound for the value of the other, but doesn't seem to indicate what the capacitor value should be. Any ideas? or have I just not looked carefully enough?
David James is offline  
Old 18th June 2008, 02:30 AM   (permalink)
Default

I think setting a resistor <40k is neccesary between MCLR and vdd now.

I searched the datasheet of 16F84A as david said a capacitor must be included and also i found out that another resistor and diode is needed.

Q> What is the value of C and diode that i must used?
Attached Images
File Type: jpg MCLR.JPG (15.3 KB, 3 views)
__________________
Hesham Ismail Mohammed Sharif
Thank me if you want
uaefame is offline  
Old 18th June 2008, 02:59 AM   (permalink)
Default

Quote:
Originally Posted by uaefame View Post
I think setting a resistor <40k is neccesary between MCLR and vdd now.

I searched the datasheet of 16F84A as david said a capacitor must be included and also i found out that another resistor and diode is needed.

Q> What is the value of C and diode that i must used?
The diode and second resistor isn't really necessary. Just put a 22K or 33K (or thereabouts) resistor between MCLR and VDD.

A 0.1uF capacitor between VDD and VSS is a good idea. Place it as close to the chip as possible.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================

Last edited by futz; 18th June 2008 at 03:00 AM.
futz is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
Visual Basic for Electronics Engineering Applications ThermalRunaway Electronic Books 25 26th November 2008 09:56 AM
It is BASIC or is it BABL 3v0 Micro Controllers 22 7th May 2007 03:09 PM
free pic basic complier dstich Micro Controllers 7 1st August 2006 08:13 PM
Assembly to Basic Coding AZdave Micro Controllers 3 23rd January 2005 03:28 PM
PIC basic and Basic stamp Cyborg Micro Controllers 5 21st April 2004 09:44 AM



All times are GMT. The time now is 09:12 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker