Go to Post And your other point, "why a debate over a nonexistent rule?". Its summer, we're not building robots, and we're geeks. What else are we supposed to do? - EHaskins [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-06-2008, 23:02
Ian Curtis Ian Curtis is offline
Best Available Data
FRC #1778 (Chill Out!)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Puget Sound
Posts: 2,521
Ian Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond repute
PIC16F877 not executing?

I realize this is kind of a long shot, but I've got the PIC in a breadboard that worked perfectly fine yesterday, using the same code that worked yesterday. I pulled out a soldered contact carrying the power supply, and didn't bother to fix it until today. But after fixing it, I don't think the code is executing. For some unknown reason, the debugger is giving me an MCLR error which I can't seem to solve, but the ICD works. It downloads the code without a problem, but when I try and run it, nothing happens. When my original code (which is supposed to control the robot based on an ultrasonic sensor) did nothing, I figured perhaps I made a mistake, so I wrote something to make an LED blink, which didn't do anything either. I checked the pins with a voltmeter, just to make sure, and didn't see any change. Also, I checked the power rails, and those are fine (+5 volts). Just for kicks, I plugged the motor controller into +5 volts, and it worked fine. I checked multiple times for loose wires, and found none.

If I fried the PIC, the code wouldn't download would it?

Is this a symptom of some other error?

I thought the most likely thing would be that I just wasn't plugging things in the right places, on the breadboard, but I've checked that more times than I can count, and tried placing them in other slots just to make sure, and there was no change.
__________________
CHILL OUT! | Aero Stability & Control Engineer
Adam Savage's Obsessions (TED Talk) (Part 2)
It is much easier to call someone else a genius than admit to yourself that you are lazy. - Dave Gingery
  #2   Spotlight this post!  
Unread 11-06-2008, 15:56
dtengineering's Avatar
dtengineering dtengineering is online now
Teaching Teachers to Teach Tech
AKA: Jason Brett
no team (British Columbia FRC teams)
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2004
Location: Vancouver, BC
Posts: 1,831
dtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond reputedtengineering has a reputation beyond repute
Re: PIC16F877 not executing?

The MCLR statement may be meaningful. It sounds like you are pretty familiar with PICs and stuff, so if I over-simplify this response, it is only to make it useful for those less familiar with the chips.

MCLR is a master reset switch, it stands for "Master Clear Reset" or something like that. If you connect it to ground, then the whole chip resets. You will note that on many PICs it is located next the the ground pin, making it easy to short the two out using a screwdriver tip, thus making it very easy to reset the PIC.

The catch is that if you don't connect the MCLR pin to something, then the voltage just kind of "floats"... in other words, it is fairly random. Yesterday it might have been high, today it might be low. To solve this problem, MCLR is typically connected to the +5 line (or whatever voltage is supplying your PIC) with a resistor. The value of the resistor doesn't really matter that much... all you are doing is making sure that the MCLR pin stays "high" except when you short it to ground.

Now, to compound things just a little bit, the PIC uses many pins for many different functions... the MCLR pin, for instance, can also be used as an I/O line (although on many PICs it can only be used as an input, I believe). If you choose to use it as an input, you cannot use it as a reset... and vice versa. You have to let the PIC know whether you want to use the MCLR pin as an input or as a reset when you download your program code. You do this by toggling a configuration bit called "MCLR Reset Enable". You can either write your configuration settings into your code (overwriting your complier/assembler's default settings), or just set them via the configuration menu of your programming software. Just make sure that if you do the setting in you programming software that if you have a "reload code before programming" option that it is turned off, or you will get the default settings back again!

So, my first suggestion is to connect the MCLR pin to your +5 supply with a resistor. Try that and see if it works. Otherwise turn off the MCLR Enable bit in your programming software and re-download your code to the PIC.

No guarantees that this is what is causing you grief, but just a couple of things that spring to mind that might be worth checking.

Jason

Edit: And if that isn't enough already, the MCLR pin is also often used to set the PIC into high-voltage programming mode... your programming device quite likely pops MCLR up to 12v at the beginning of your code download. Something to keep in mind when doing in-circuit (where you don't take the chip off the board) programming!

Last edited by dtengineering : 11-06-2008 at 15:59.
  #3   Spotlight this post!  
Unread 11-06-2008, 18:01
MCahoon MCahoon is offline
Registered User
FRC #3826 (Sequim Robotics Federation)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2007
Location: Sequim, WA
Posts: 129
MCahoon has much to be proud ofMCahoon has much to be proud ofMCahoon has much to be proud ofMCahoon has much to be proud ofMCahoon has much to be proud ofMCahoon has much to be proud ofMCahoon has much to be proud ofMCahoon has much to be proud ofMCahoon has much to be proud of
Re: PIC16F877 not executing?

My experience has been similar to Jason's, such that I always put about a 22K pullup on the MCLR. I can't say I've observed a MCLR error, since I don't have access to an In Circuit Debugger (I use a PICKIT 2 ICSP, but the chips I use don't support the debug feature).

The other thing I've noted is to make sure you disable the low voltage programming, else almost any noise on the PGM pin will tend to interrupt the program and cause the device to attempt to go into a programming mode. My quick test for this is if the chip

At last, but I feel most likely, try connecting a 1 microfarad capacitor (I use a ceramic non-polarized) between power and ground fairly close to the power pins on the chip. I have had a number of PIC designs which would run off the power supply provided by the ICSP, but when connected to a 5 V power supply they would simply stop. The capacitor always corrected that.
  #4   Spotlight this post!  
Unread 14-06-2008, 23:39
JBotAlan's Avatar
JBotAlan JBotAlan is offline
Forever chasing the 'bot around
AKA: Jacob Rau
FRC #5263
Team Role: Mentor
 
Join Date: Sep 2004
Rookie Year: 2004
Location: Riverview, MI
Posts: 723
JBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond reputeJBotAlan has a reputation beyond repute
Send a message via AIM to JBotAlan Send a message via Yahoo to JBotAlan
Re: PIC16F877 not executing?

Spam post reported.
__________________
Aren't signatures a bit outdated?
  #5   Spotlight this post!  
Unread 19-06-2008, 08:55
steveg's Avatar
steveg steveg is offline
Livin' the Dream
AKA: Stephen Guerrera
no team
Team Role: Mentor
 
Join Date: Jan 2003
Rookie Year: 2003
Location: Boston, MA
Posts: 70
steveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to beholdsteveg is a splendid one to behold
Send a message via AIM to steveg
Re: PIC16F877 not executing?

I usually use a 10K resistor to pull MCLR up. You should probe that pin with a voltmeter to see where it is. You might have a solder bridge or other short somewhere that's messing you up.

The next thing to check is that your crystal or oscillator if you're not using the internal oscillator is functioning as it should. I've seen PICs get into a strange states and do weird things when their crystal/oscillator isn't working correctly. You should see a nice, strong signal at OSC1 if everything is working.
__________________
Steve Guerrera

-2003 T.R.I.B.E. 237
2004-2008 Nutrons 125

Boston Regional Mentor
MIT Grad Student
  #6   Spotlight this post!  
Unread 20-06-2008, 11:31
Ian Curtis Ian Curtis is offline
Best Available Data
FRC #1778 (Chill Out!)
Team Role: Engineer
 
Join Date: Feb 2005
Rookie Year: 2004
Location: Puget Sound
Posts: 2,521
Ian Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond reputeIan Curtis has a reputation beyond repute
Re: PIC16F877 not executing?

Thanks for all your responses, if it decides it doesn't like in the future I'll certainly come back here to look. It ended up that it wanted some fuses set in the code. I'm not sure why it wanted them at first, and not later, but it fixed it.
__________________
CHILL OUT! | Aero Stability & Control Engineer
Adam Savage's Obsessions (TED Talk) (Part 2)
It is much easier to call someone else a genius than admit to yourself that you are lazy. - Dave Gingery
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
IR Board Not Working (But NOT Fried) itsme Electrical 2 18-02-2008 06:11
Not GP vs. GP Taylor Games/Trivia 37 27-10-2006 18:54
Interrupt timer, executing code asap? SeanCassidy Programming 10 07-03-2004 01:47
Match Pairings not random (not even close!) Norm M. General Forum 74 31-03-2003 08:22
To be or not to be Chubtoad Chit-Chat 17 19-03-2002 07:01


All times are GMT -5. The time now is 19:21.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi