Code not running on PIC16F88 when pic kit 3 is disconnected

Started by Andrew September 9, 2010
Hi,

I have a project where I have a PI16F88 to communicate with a PC via RS232, and control a relay, and read an ADC. When I have the PIC kit 3 interface connected to my board and MPLAB is communicating with the PIC my code works fine. As soon as I disconnect the PIC kit 3 from my board, and reset the power the code stops running.

I have a 1k resistor pulling MCLR to 5V, and a 0.1uF capacitor from MCLR to Ground.

I'm using the internal oscillator at 8MHz. My fuse settings are:
#fuses INTRC,NOWDT,PUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,MCLR
#device ADC
#use delay(clock00000)
#use rs232(baud$00,bits=8,parity=N,xmit=PIN_B5,rcv=PIN_B2,stream=PC,UART1)
Can someone shed some light on my problem for me please?
_________________
Kind regards

Andrew Ellis

On 09/09/2010 12:02, Andrew wrote:
> Hi,
>
> I have a project where I have a PI16F88 to communicate with a PC via RS232, and control a relay, and read an ADC. When I have the PIC kit 3 interface connected to my board and MPLAB is communicating with the PIC my code works fine. As soon as I disconnect the PIC kit 3 from my board, and reset the power the code stops running.
>
> I have a 1k resistor pulling MCLR to 5V, and a 0.1uF capacitor from MCLR to Ground.
>
> I'm using the internal oscillator at 8MHz. My fuse settings are:
> #fuses INTRC,NOWDT,PUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,MCLR
> #device ADC
> #use delay(clock00000)
> #use rs232(baud$00,bits=8,parity=N,xmit=PIN_B5,rcv=PIN_B2,stream=PC,UART1)
> Can someone shed some light on my problem for me please?
Are you actually programming the chip, rather than using the debugger?

Leon
--
Leon Heller
G1HSM
Thanks for you prompt reply Leon.

I have gone to the menu item:

Programmer->Select Programmer->4 PIC kit 3

I then go to:

Programmer-> Erase flash device

Then:

Programmer->Program.

So I'm confident that the code is being loaded into the device.

Is there something else that I'm missing?

Kind regards

Andrew

--- In p..., Leon Heller wrote:
>
> On 09/09/2010 12:02, Andrew wrote:
> > Hi,
> >
> > I have a project where I have a PI16F88 to communicate with a PC via RS232, and control a relay, and read an ADC. When I have the PIC kit 3 interface connected to my board and MPLAB is communicating with the PIC my code works fine. As soon as I disconnect the PIC kit 3 from my board, and reset the power the code stops running.
> >
> > I have a 1k resistor pulling MCLR to 5V, and a 0.1uF capacitor from MCLR to Ground.
> >
> > I'm using the internal oscillator at 8MHz. My fuse settings are:
> >
> >
> > #fuses INTRC,NOWDT,PUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,MCLR
> > #device ADC
> > #use delay(clock00000)
> > #use rs232(baud$00,bits=8,parity=N,xmit=PIN_B5,rcv=PIN_B2,stream=PC,UART1)
> >
> >
> > Can someone shed some light on my problem for me please?
> Are you actually programming the chip, rather than using the debugger?
>
> Leon
> --
> Leon Heller
> G1HSM
>

On 09/09/2010 12:27, Andrew wrote:
> Thanks for you prompt reply Leon.
>
> I have gone to the menu item:
>
> Programmer->Select Programmer->4 PIC kit 3
>
> I then go to:
>
> Programmer-> Erase flash device
>
> Then:
>
> Programmer->Program.
>
> So I'm confident that the code is being loaded into the device.
>
> Is there something else that I'm missing?
Have you disabled the analogue functions (if any) on the I/O pins? It's
done automatically by the debugger, but you need to do it yourself for a
stand-alone application. People often miss it.

Leon
--
Leon Heller
G1HSM
Is it possible that you haven't changed to project from "Debug" to "Release". I can't remember if chosing your programmer type implies that you've already changed this setting. I have forgotten this before.

Best Wishes, and keep us posted,
Coop, AA1WW

To: p...
From: l...@btinternet.com
Date: Thu, 9 Sep 2010 12:56:44 +0100
Subject: Re: [piclist] Re: Code not running on PIC16F88 when pic kit 3 is disconnected

On 09/09/2010 12:27, Andrew wrote:
> Thanks for you prompt reply Leon.
>
> I have gone to the menu item:
>
> Programmer->Select Programmer->4 PIC kit 3
>
> I then go to:
>
> Programmer-> Erase flash device
>
> Then:
>
> Programmer->Program.
>
> So I'm confident that the code is being loaded into the device.
>
> Is there something else that I'm missing?

Have you disabled the analogue functions (if any) on the I/O pins? It's
done automatically by the debugger, but you need to do it yourself for a
stand-alone application. People often miss it.

Leon
--
Leon Heller
G1HSM
Hi Leon, and Jeffery,

I found the solution to my problem. I needed to add the following line to my main() function:

setup_oscillator(OSC_8MHZ);

I stumbled across that whilst trying to work out how to disable the analogue functions on some of the pins.

Jeffery I couldn't find the option in the MPLAB to change between debug and release. Does it exist in MPLAB. I have certainly come across that feature in other IDEs for other micro's.

Thanks very much for you time and help.

Andrew

--- In p..., "Jeffrey L. Cooper" wrote:
> Is it possible that you haven't changed to project from "Debug" to "Release". I can't remember if chosing your programmer type implies that you've already changed this setting. I have forgotten this before.
>
> Best Wishes, and keep us posted,
> Coop, AA1WW
>
>
> To: p...
> From: leon355@...
> Date: Thu, 9 Sep 2010 12:56:44 +0100
> Subject: Re: [piclist] Re: Code not running on PIC16F88 when pic kit 3 is disconnected
>
>
> On 09/09/2010 12:27, Andrew wrote:
> > Thanks for you prompt reply Leon.
> >
> > I have gone to the menu item:
> >
> > Programmer->Select Programmer->4 PIC kit 3
> >
> > I then go to:
> >
> > Programmer-> Erase flash device
> >
> > Then:
> >
> > Programmer->Program.
> >
> > So I'm confident that the code is being loaded into the device.
> >
> > Is there something else that I'm missing?
>
> Have you disabled the analogue functions (if any) on the I/O pins? It's
> done automatically by the debugger, but you need to do it yourself for a
> stand-alone application. People often miss it.
>
> Leon
> --
> Leon Heller
> G1HSM
>

Andrew:

Nice going on finding the answer. It reminds me that when going from "Debug" to "Release" there are several things one ought to check (and this is likely to be incomplete):
- Device configuration bits/settings.
- Is your reset circuitry correct?
- What states are your I/O pins in as you power up?
- Oscillator setup (as you mentioned).
- MPLAB Main Menu Bar -> Project -> Biuld Configuration -> Debug/Release.

When your project is configured for "Debug", your PICkit or ICD will set some things for you and you can get something up and running quickly. However, when you're ready to put your chip into a project board you obviously have to cross all of your t's and dot all of your i's.

Doublecheck anything I've said!

Best wishes,
Coop, AA1WW

PS: I have to remind myself of a similar set of things when I "clone" a project by creating a new project/workspace and copy code files, etc. into the new project. Device configuration bits, debugger options, etc. need to be checked.

To: p...
From: a...@yahoo.co.uk
Date: Fri, 10 Sep 2010 08:58:22 +0000
Subject: [piclist] Re: Code not running on PIC16F88 when pic kit 3 is disconnected

Hi Leon, and Jeffery,

I found the solution to my problem. I needed to add the following line to my main() function:

setup_oscillator(OSC_8MHZ);

I stumbled across that whilst trying to work out how to disable the analogue functions on some of the pins.

Jeffery I couldn't find the option in the MPLAB to change between debug and release. Does it exist in MPLAB. I have certainly come across that feature in other IDEs for other micro's.

Thanks very much for you time and help.

Andrew

--- In p..., "Jeffrey L. Cooper" wrote:
> Is it possible that you haven't changed to project from "Debug" to "Release". I can't remember if chosing your programmer type implies that you've already changed this setting. I have forgotten this before.
>
> Best Wishes, and keep us posted,
> Coop, AA1WW
> To: p...
> From: leon355@...
> Date: Thu, 9 Sep 2010 12:56:44 +0100
> Subject: Re: [piclist] Re: Code not running on PIC16F88 when pic kit 3 is disconnected
> On 09/09/2010 12:27, Andrew wrote:
> > Thanks for you prompt reply Leon.
> >
> > I have gone to the menu item:
> >
> > Programmer->Select Programmer->4 PIC kit 3
> >
> > I then go to:
> >
> > Programmer-> Erase flash device
> >
> > Then:
> >
> > Programmer->Program.
> >
> > So I'm confident that the code is being loaded into the device.
> >
> > Is there something else that I'm missing?
>
> Have you disabled the analogue functions (if any) on the I/O pins? It's
> done automatically by the debugger, but you need to do it yourself for a
> stand-alone application. People often miss it.
>
> Leon
> --
> Leon Heller
> G1HSM
>
Could it be a watchdog timer that is turned off while connected to the
debugger and then kicking off when you run untethered?
On Sep 9, 2010, at 4:27 AM, Andrew wrote:

> Thanks for you prompt reply Leon.
>
> I have gone to the menu item:
>
> Programmer->Select Programmer->4 PIC kit 3
>
> I then go to:
>
> Programmer-> Erase flash device
>
> Then:
>
> Programmer->Program.
>
> So I'm confident that the code is being loaded into the device.
>
> Is there something else that I'm missing?
>
> Kind regards
>
> Andrew
>
> --- In p..., Leon Heller wrote:
>>
>> On 09/09/2010 12:02, Andrew wrote:
>>> Hi,
>>>
>>> I have a project where I have a PI16F88 to communicate with a PC
>>> via RS232, and control a relay, and read an ADC. When I have the
>>> PIC kit 3 interface connected to my board and MPLAB is
>>> communicating with the PIC my code works fine. As soon as I
>>> disconnect the PIC kit 3 from my board, and reset the power the
>>> code stops running.
>>>
>>> I have a 1k resistor pulling MCLR to 5V, and a 0.1uF capacitor
>>> from MCLR to Ground.
>>>
>>> I'm using the internal oscillator at 8MHz. My fuse settings are:
>>>
>>>
>>> #fuses INTRC,NOWDT,PUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,MCLR
>>> #device ADC
>>> #use delay(clock00000)
>>> #use
>>> rs232
>>> (baud$00,bits=8,parity=N,xmit=PIN_B5,rcv=PIN_B2,stream=PC,UART1)
>>>
>>>
>>> Can someone shed some light on my problem for me please?
>> Are you actually programming the chip, rather than using the
>> debugger?
>>
>> Leon
>> --
>> Leon Heller
>> G1HSM
>>
>
>
> to unsubscribe, go to http://www.yahoogroups.com and follow the
> instructions
Em 9/9/2010 08:02, Andrew escreveu:
>
>
> Hi,
>
> I have a project where I have a PI16F88 to communicate with a PC via
> RS232, and control a relay, and read an ADC. When I have the PIC kit 3
> interface connected to my board and MPLAB is communicating with the
> PIC my code works fine. As soon as I disconnect the PIC kit 3 from my
> board, and reset the power the code stops running.
>
> I have a 1k resistor pulling MCLR to 5V, and a 0.1uF capacitor from
> MCLR to Ground.
>
> I'm using the internal oscillator at 8MHz. My fuse settings are:
>
> #fuses INTRC,NOWDT,PUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,MCLR
> #device ADC
> #use delay(clock00000)
> #use
> rs232(baud$00,bits=8,parity=N,xmit=PIN_B5,rcv=PIN_B2,stream=PC,UART1)
>
> Can someone shed some light on my problem for me please?
> _________________
> Kind regards
>
> Andrew Ellis
>
Did you change in MPLAB the "Build Configuration" to "Release" before
rebuilding the project? Did you rebuild the project before programming?
Did you change the PIC KIT 3 from "Debugger" to "Programmer" mode?
Best regards,

Isaac
Hi,

Thanks for your replies.

It seems my problem has come back.

It looks like I failed to mention that I'm using the CCS C compiler.

I am confident the Watchdog timer is disabled because I have set the NOWDT fuse. I don't seem to be able to change between Debug and Release build. The drop down menu on the toolbar is greyed out and the menu item "Project->Build configurations" says that there are no build configurations.

Does anyone have any further suggestions for things I could try please.

Thanks

Andrew

--- In p..., Isaac Marino Bavaresco wrote:
>
> Em 9/9/2010 08:02, Andrew escreveu:
> >
> >
> > Hi,
> >
> > I have a project where I have a PI16F88 to communicate with a PC via
> > RS232, and control a relay, and read an ADC. When I have the PIC kit 3
> > interface connected to my board and MPLAB is communicating with the
> > PIC my code works fine. As soon as I disconnect the PIC kit 3 from my
> > board, and reset the power the code stops running.
> >
> > I have a 1k resistor pulling MCLR to 5V, and a 0.1uF capacitor from
> > MCLR to Ground.
> >
> > I'm using the internal oscillator at 8MHz. My fuse settings are:
> >
> > #fuses INTRC,NOWDT,PUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NOWRT,MCLR
> > #device ADC
> > #use delay(clock00000)
> > #use
> > rs232(baud$00,bits=8,parity=N,xmit=PIN_B5,rcv=PIN_B2,stream=PC,UART1)
> >
> > Can someone shed some light on my problem for me please?
> > _________________
> > Kind regards
> >
> > Andrew Ellis
> >
> Did you change in MPLAB the "Build Configuration" to "Release" before
> rebuilding the project? Did you rebuild the project before programming?
> Did you change the PIC KIT 3 from "Debugger" to "Programmer" mode?
> Best regards,
>
> Isaac
>