Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC flashes the LED on power up without a reason!

Status
Not open for further replies.

sayfollah

Newbie level 6
Newbie level 6
Joined
Oct 3, 2005
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,425
PIC power on problem

I am using PIC 12F675 .

My project is a simple count down that flashes an LED after several minutes .

I got a problem that the IC , sometimes, flashes the LED on power up before executing the program .

The LED is supposed not to flash until the "DELAY" subroutine is finished .

This is a part of my program :

org 0x00
clrf GPIO
GOTO MAIN

FIRST bcf STATUS, RP0
clrf INTCON
bsf STATUS, RP0
call 3FFh
movwf OSCCAL
movlw B'00111000'
movwf TRISIO
movlw B'00000100'
movwf OPTION_REG
bcf STATUS, RP0
retlw 00h

MAIN CALL FIRST
CALL DELAYmin
bsf GPIO, 2

You can guess that I am a beginner .

How can I overcome this problem ?
 

Re: PIC power on problem

You need to provide more information such as a circuit diagram and the complete code listing.
 

PIC power on problem

The circuit diagram is very simple .

Just a 6V battery and an LED + resistor connected to pin 5 to ground .

The program is working well. Just when I connect the battery , the IC flashes the LED (not always) .

the code quoted above is the whole code w/o the delay subroutine and the definition of registers . I didn't hide any other piece of it !
 

Re: PIC power on problem

You also need to look at some details such as the configuration word when programming.

make sure that the Brownout, the Power on timer, the Wach Dog, and some other features are at known state according to your purposes.

For example, if by any chance you the watch dog enabled (and your program does not reset it) you might have problems to get your program do what you want it to.
 

PIC power on problem

thanks for your response

The watchdog timer is disabled .
The MCLR is disabled
The brown-out is disabled
The PWRTE is enabled
and Iam using the internal 4MHz oscillator

The problem occurs just at power on , not while executing the program .
 

Re: PIC power on problem

Try to connect 10-100µF electrolytic or tantalum cap between Vdd(pin1) and Vss(pin8) and try again ..

Regards,
IanP
 

Re: PIC power on problem

use a 10k resistor with the /MCLR pin to Vcc for proper resetting.
 

Re: PIC power on problem

check fuses and disable brownout reset
 

Re: PIC power on problem

I have just remebered that 12f675 has an analog converter, or comparator.

In that case, along with the TRISIO, you also need to set values for teh ANSEL register. Unfortunetly by default, on startup, this pins are analog, so your led would not be controlled by a digital pin.

So I would say:
bsf STATUS, RP0
call 3FFh
movwf OSCCAL
movlw B'00111000'
movwf TRISIO

clrf ANSEL ************

movlw B'00000100'
movwf OPTION_REG
bcf STATUS, RP0

Added after 7 minutes:

Almost forgot, there is also a comparator module, that makes those pins analog at startup, son you also need to set them digital with

movlw B'00000111'
movwf CMCON

Good luck!!!
 

PIC power on problem

I am sorry to say that neither solution has worked , though the occurance of the problem reduced .

I put 100uF b/w Vdd and Vss , enabled the MCLR with pin4 connected to Vdd through resistor , defined all pins as digital I/O , the brown-out is disabled already , and the problem still occurs . :)

I did some checks on the IC . I found that no other pins gives voltage on power-on except the one I assigned as the output of the "result" . In our case "GP2" , or no output from GP0 and GP1 (which are configured also as outputs ) .

Maybe , this means that the problem isn't hardware problem . I don't know . So , Any more help :)

Thanx for your help
 

Re: PIC power on problem

For me most of these problems can be found with the simulator in the mplab enviroment (free at microchip site)

There you can set up watches for TRISO, GPIO, CMCON, ANSEL and any other register involved.

There you will have the problem "almost" like with the circuit in veroboard.

You can also measure time, set breakpoints and so on.

This tool is much better than any advice that can be given to you from the distance.

If it is a soft problem there is a 99% chance you will have it there with the advantage that you will have a full access to all the PIC registers to look at.

PD. Just before I metioned to set CMCON, check for it, I think it is in an upper bank, so RP0 must be set

Added after 1 minutes:

Here you can also notice when your pins are not digital, like it seems to be your case here
 

    sayfollah

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top