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.

Do PIC18's need software initialization or hardware setup to start executing code?

Status
Not open for further replies.

myru28

Member level 1
Joined
Jun 22, 2012
Messages
33
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Activity points
1,558
I've a code written for a PIC18F4620 that executes right on MPLAB on Debug mode.

But if the program is not being debugged it doesn't run at all, despite the only things that I change are that I eliminate Pickit2 wires from the board and I connect a 10 K resistor tied to 5V to the MCLR pin. (I'm sending 5 V from a external voltage also in debugging mode).

In fact on a PIC16F this problem hasn't appeared (moreover, I couldn't debug it so I just checked that it worked when I connected 5V with 10 K to MCLR, 5V to VDD, GND to GND pin and 4 Mhz quartz crystal along with their capacitors to the corresponding PIC16 pins and GND), so it might be something related to this family of microcontrollers.

Any idea?
 

You shouldnt connect MCLR to 5V just through the resistor you should use a simple timing circuit,
this pin resets/starts the pic, so you should let the pic have some time with connected power supply
before you resets it.

Try adding this circuit:
reset_circuit_18f.gif
or use POR (power on reset), you can enable it in configuration bits.
 

You have to compile the code for 'release' not debug.
It wont run if you have debug code in it.
 

You have to compile the code for 'release' not debug.
It wont run if you have debug code in it.

Was already in release.

You shouldnt connect MCLR to 5V just through the resistor you should use a simple timing circuit,
this pin resets/starts the pic, so you should let the pic have some time with connected power supply
before you resets it.

Try adding this circuit:
View attachment 79028
or use POR (power on reset), you can enable it in configuration bits.

I added the circuit but no result.

I think my particular PIC (PIC18F4620 doesn't have POR bit) as it doesn't appear in configuration bits and even if I set in code #pragma config POR=ON it doesn't compile. I also tried to change PWRT bit, but it doesn't also work.

Thanks a lot for your help.

PD: Well I checked now that it's not that it doesn't exist, it exists nto the RCON register but as this register has to be used in code it's no use... unless I'm losing something.
 
Last edited:

Post, using CODE or SYNTAX tags, or upload your code.

Give a brief description of your codes expected function.


You state the code performs as expected in Debug mode, is this by single stepping or free running the code?

Have you installed proper bypass capacitors between Vdd and Vss?


BigDog
 

How you generate clock signal for PIC; it may not be working.
If you have used crystal check, Oscillator and it's parallel-capacitors; they must be there and good.
 

Hello,
show us all configuration bits .
debug bit on ?
and post your code...
 

bigdogguru said:
Post, using CODE or SYNTAX tags, or upload your code.

Give a brief description of your codes expected function.


You state the code performs as expected in Debug mode, is this by single stepping or free running the code?

Have you installed proper bypass capacitors between Vdd and Vss?

Code doesn't mind, I tested with a simpler program with the same configuration bits and it acts the same way.

Code performs right either way in debug mode.

I had forgotten to put them, but I put them now and effect was the same.

Hello,
show us all configuration bits .
debug bit on ?
and post your code...

On debugbits attachment.

Hadn't set it but I set it to off and same result.

How you generate clock signal for PIC; it may not be working.
If you have used crystal check, Oscillator and it's parallel-capacitors; they must be there and good.

I'm using a 4 Mhz quartz crystal with 22 pF capacitors and in debug mode they are working right, I don't see a reason they shouldn't work without debug.

Anyway I guess the fault has to be on the MCLR pin rather in other places, I guess my Pickit2 clone generates some signals that allow to start the execution of code,so ... does anyone know where to find documentation about how to generate this signals? I tried to find it but with no result.
 

Attachments

  • debugbits.JPG
    debugbits.JPG
    189.1 KB · Views: 75

Anyway I guess the fault has to be on the MCLR pin rather in other places, I guess my Pickit2 clone generates some signals that allow to start the execution of code,so ... does anyone know where to find documentation about how to generate this signals? I tried to find it but with no result.

No special signal; It only pull up the MCLR; In debug mode, clock is given by Pickit2. Your oscillator only come up to action in normal running. Hence that kind of situations, oscillators were found faulty in most of the times.
Like bigdog has suggested, place bypass capacitors close to PIC and use stable and capable power supply. Disable BOREN completely.
If it is possible, run the code in different circuit board, without other hardware around the PIC. That will help to figure out any power problems and faulty oscillator.
 

When an issue arises, the wiser man will consider all possibilities, rather than repeatedly deny any possibility.


You will not post the source code, disclose the Configuration Register settings nor entertained the possibility of a faulty oscillator.

It can't possibly be this, it can't possibly be that.

Obviously, something is DEFINITELY amiss.


You have had several forum members attempt to assist you, all of whom raise legitimate concerns and yet you have failed to provide any of the additional information they have requested nor entertained the possible issues they present.


So why waste your time and theirs?



BigDog
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top