View previous topic :: View next topic |
Author |
Message |
feitanx
Joined: 21 Mar 2010 Posts: 37
|
When I turn On |
Posted: Sun Jun 13, 2010 4:47 am |
|
|
Supposedly when you program a pic and turn it on again it should run correctly but when I turn it on again it runs incorrectly?
what is the problem? is it the fuse? |
|
|
SherpaDoug
Joined: 07 Sep 2003 Posts: 1640 Location: Cape Cod Mass USA
|
|
Posted: Sun Jun 13, 2010 6:17 am |
|
|
You need to give us more information. Can you post a short program with the fuse lines, the PIC declaration and your compiler version? _________________ The search for better is endless. Instead simply find very good and get the job done. |
|
|
feitanx
Joined: 21 Mar 2010 Posts: 37
|
|
Posted: Sun Jun 13, 2010 7:45 am |
|
|
#include <16F877a.h>
#fuses XT,NOWDT,NOPROTECT,NOLVP,NOCPD,NOBROWNOUT,NOWRT
CCS VERSION IS PCWHD 4.078 |
|
|
P51D
Joined: 25 Jan 2010 Posts: 36
|
|
Posted: Sun Jun 13, 2010 10:07 am |
|
|
What about the MCLR?
Do you use it? external Pull-Up-resistor
->
#fuse MCLR
Is the programmer still connected?
What is it for a programmer?
What doesn't work right?
...
Describe the problem.
best wishes
P51D |
|
|
feitanx
Joined: 21 Mar 2010 Posts: 37
|
|
Posted: Sun Jun 13, 2010 9:02 pm |
|
|
The problem is when I turn on the PIC again there is no output and sometimes an error output. It should produce a correct output when you supply voltage to the pic right?
What's the use of #fuse mclr?
I place a 1k pullup between vdd and mclr. |
|
|
P51D
Joined: 25 Jan 2010 Posts: 36
|
|
Posted: Mon Jun 14, 2010 12:10 am |
|
|
feitanx wrote: | The problem is when I turn on the PIC again there is no output and sometimes an error output. It should produce a correct output when you supply voltage to the pic right?
What's the use of #fuse mclr?
|
1. What for a output?
Post c-file and h-file. In the moment it is a riddle to find the problem an a lottery to find the solutions.
2. Some PIC's have more functions at the MCLR pin (normal port operation). If you have something like this, you should to activate the MCLR so your programmer can hold the pic in a reset while the programming is active.
Try this fuse-settings:
Code: |
#device *=16
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES XT //Crystal osc <= 4mhz for PCM/PCH , 3mhz to 10 mhz for PCD
#FUSES PUT //Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#FUSES RESERVED //Used to set the reserved FUSE bits
#use delay(clock=20000000,RESTART_WDT)
|
What for an oscillator do you use?
best wishes
P51D |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Mon Jun 14, 2010 4:20 am |
|
|
The most likely reason for a problem of this sort, is that in fact part of the circuit is not actually going 'off'....
If (for instance), you have a supply with capacitors on it, that feeds some 'power' circuitry (anything, lights, relays, etc..), and is then regulated to feed a processor like the PIC, and you have further capacitance on this regulated rail, it is common to find that when power is removed, the incoming rail drops in a few seconds to basically nothing, but the rail feeding the processor, takes several seconds, or even minutes, to actually drop to the point where everything turns 'off'. With some regulators (such as the 78xx series), this can be an easy way to destroy the regulator. When the incoming rail drops below the regulated rail, current starts to flow backwards through the regulator, and can kill it. On these, it is always recommended that a reverse diode is placed across the regulator to protect it from this, and also to speed up the discharge of the second rail...
If the rail is partially dropping, but not getting low enough to reset the processor, then the 'BROWNOUT' fuse as already suggested, will help.
Best Wishes |
|
|
feitanx
Joined: 21 Mar 2010 Posts: 37
|
|
Posted: Mon Jun 14, 2010 6:13 am |
|
|
I use a 4 mhz crystal oscillator(ECS-40-20-1)
what does brownout and powerup do?
why is there a restart_wdt in the delay?
What do you mean in the rail? what is your point? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Mon Jun 14, 2010 6:56 am |
|
|
feitanx wrote: | I use a 4 mhz crystal oscillator(ECS-40-20-1) | This is a "crystal", not a "crystal oscillator". Use the XT fuse for this (and not HS or EC !!)
Quote: | what does brownout and powerup do? | I don't mind explaining to you, but I hate typing info that is already available. Have you tried reading the PIC datasheet? For the PIC16F877A these terms are explained in chapter 14.4 - 14.8.
Also read the Application Note 607 "Power-up Trouble Shooting"
Quote: | why is there a restart_wdt in the delay? | The watchdog is disabled with the fuse NOWDT, so this restart_wdt parameter is useless and is better left out.
Quote: | What do you mean in the rail? |
From wikipedia: "A power supply rail or voltage rail refers to a single voltage provided by a power supply unit (PSU) relative to some understood ground."
Simply said: The (positive) supply voltage in your circuit.
Quote: | what is your point? | The point is that when you 'think' the circuit is switched off, it takes some time for all energy to leave the circuits. Depending on your design this can take up to 10 seconds or more. Switching on the circuit too soon can result in only a partial reset of the processor with strange behaviour as you see. The Brown-out circuit in the PIC is designed to create a defined reset signal for these situations. Enable this feature by setting the BROWNOUT fuse.
Last edited by ckielstra on Mon Jun 14, 2010 6:59 am; edited 1 time in total |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19544
|
|
Posted: Mon Jun 14, 2010 6:58 am |
|
|
Brownout, forces the processor to reset, if the supply rail to the chip drops below about 4v.
Put, holds the chip reset for a few mSec after the supply goes 'good'. Makes it less likelythat you will get 'on-off-on' operation if the supply takes a few mSec to rise.
These are described in the data sheet. Read it.
'Rail', is a common name for the supply lines feeding parts of the circuitry. It dates from 'history', where it was common to actually have physical metal 'bars' (bus-bars, or 'rails'), feeding supplies. Common term used in the PIC data sheets in places (for your chip Microchip refer to the OSC signal as being 'rail-to-rail').
Do some basic electrical reading, I have already made my 'point', learn how to understand it. If you don't have the basic electrical knowledge needed to read this, then I'd be suspicious of your whole 'design'...
Best Wishes |
|
|
feitanx
Joined: 21 Mar 2010 Posts: 37
|
|
Posted: Mon Jun 14, 2010 8:26 pm |
|
|
When you say reset, what do you mean?
Is it the program in the memory will be erased?
The problem still persist. When I it turn on after I turn it off for a while , the pic doesnt run and erroneous sometimes |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue Jun 15, 2010 5:41 am |
|
|
Quote: |
what does brownout and powerup do?
why is there a restart_wdt in the delay?
What do you mean in the rail? what is your point?
It should produce a correct output when you supply voltage to the pic right?
What's the use of #fuse mclr?
what is the problem?
is it the fuse?
When you say reset, what do you mean?
Is it the program in the memory will be erased?
|
It is not easy to help you in this forum. All these questions tell us that you need is to know some
basic concepts of microcontrollers, this is not the right place.
In this forum you will find the best of us asking for an specific issue, not for a explanation of each
feature of PIC hardware. I hope not being offensive with this.
Search in this forum for "books" or "tutorial" and you will find usefull info regarding this.
Regards,
Humberto |
|
|
feitanx
Joined: 21 Mar 2010 Posts: 37
|
|
Posted: Tue Jun 15, 2010 8:29 am |
|
|
I read some pdf but I dont know what will happen in detail if a reset will occur. |
|
|
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Tue Jun 15, 2010 10:04 am |
|
|
Quote: |
I read some pdf but I dont know what will happen in detail if a reset will occur.
|
We expect that you should know the devices involved in your project.
Tell us about your hardware, are you using a standard board (like PICDEM or similar development
tool) or a breadboard with inserted components?
How is the power source and of what type? batteries, AC transformer, DC regulated?
Tell us about the main circuit, describe 16F877 wired pins, Vcc, Gnd, OSC, MCLR, etc.
Regardos,
Humberto |
|
|
P51D
Joined: 25 Jan 2010 Posts: 36
|
|
|
|