CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Code runs in debugger but not standalone

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hucker



Joined: 25 Jan 2017
Posts: 7

View user's profile Send private message

Code runs in debugger but not standalone
PostPosted: Thu Feb 09, 2017 7:41 pm     Reply with quote

I have a project running on a 16F887 processor using MPLAB as my build/debug environment. In this environment the code is running fine however if I disconnect the ICD3 and try to run the programmed code the device does not start up...I have an LED that lights very early in the boot and it never flickers.

I have checked this FAQ

http://www.ccsinfo.com/faq.php?page=standalone

Since I build from the MPLab environment it is not clear what I need to do to run with regard to disabling the debugger for PCW. I do have the debugger disabled in PCW and have selected the release build option in MPLab.

here is my #FUSE code

Code:

#define DEBUG_MODE
#ifdef DEBUG_MODE
#device ICD=True
#fuses HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD
#fuses DEBUG
#else
#fuses HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD
#fuses NODEBUG
#endif


I'm not sure where to look to troubleshoot this as the FUSE command takes details of micro configuration out of my hands. Any direction would be appreciated!

Thx.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Feb 09, 2017 8:21 pm     Reply with quote

When using MPLAB , the 'build configuration' must be set to 'release' and not 'debug'then recompile then burn the PIC.

My install of MPLAB has 'release' permanently selected as I never use 'debug'.

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 12:17 am     Reply with quote

Quote:
I do have the debugger disabled in PCW.

What does that mean ? How did you do it ?


Your fuses as posted are enabling debug mode. To fix this, comment out
the top line as shown below.
Quote:
// #define DEBUG_MODE
#ifdef DEBUG_MODE
#device ICD=True
#fuses HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD
#fuses DEBUG
#else
#fuses HS,NOWDT,NOPROTECT,NOPUT,NOBROWNOUT,NOLVP,NOCPD
#fuses NODEBUG
#endif
hucker



Joined: 25 Jan 2017
Posts: 7

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 12:33 pm     Reply with quote

When I build for release I do comment that line out.

When I compile from MPLab, I am using the CCS compiler using the plugin. I have never enabled the debugger in CCS (e.g. no debugging tools are selected from the "Enable" button on the debug screen.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 12:58 pm     Reply with quote

The obvious comments/questions are:

What is on the MCLR line?. Needs something to pull it up when the ICD is not connected.
Look carefully at the ground and PSU connections. Remember the ICD will connect these to the chip.
Remember you have to compile the code without DEBUG & load this into the chip, in 'programmer' mode. The code put into the chip when ICD is enabled will not run without the ICD connection.
Be aware that MPLAB always defaults to compiling with DEBUG enabled, even if a debugger is not selected. You have to explicitly select 'release' for it to not do this.
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 2:45 pm     Reply with quote

MPLAB defaults to 'debug' mode for the 'build configuration'. It has to be set to 'release' in order for the code to be correctly compiled to burn a PIC for Real world use.

Jay
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 2:55 pm     Reply with quote

He said that in his first post. He said:
Quote:

I do have the debugger disabled in PCW and
have selected the release build option in MPLab.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 3:02 pm     Reply with quote

I was slightly 'dubious', since he seems to think that not having a debugger disabled it. Not true.
hucker



Joined: 25 Jan 2017
Posts: 7

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 3:08 pm     Reply with quote

I have been setting release mode and changing the defines around when I build. I believe this is not related to the programming environment at this time.

It does appear that this is an MCLR issue. When the board was redesigned (16F877 to 16F887) the mcrl pullup with diode protection was not included (not sure why). Thanks Ttelmah!

I notice that there are MCLR and NOMCLR fuse settings for the 887 while the 877 does not have these fuses. Can this compiler fuse setting be used to get the PIC to boot from code or do I need to deadbug the pullup/diode? (the MCLR pin is only used for programming in our system).
hucker



Joined: 25 Jan 2017
Posts: 7

View user's profile Send private message

PostPosted: Fri Feb 10, 2017 5:45 pm     Reply with quote

There are a lot of things going on here and everybody seems to have opinions, some of them "dubious", as to how programming and debugging work using MPLab. Here are a few points worth noting:

I am using MPLAB 8.92 and have it configured to use the CCS compiler using the MPLab integration tool from CCS. Under this configuration I have discovered the following:

1) There is a release/debug option on the MPLab compiler.
2) There is a code directive #device ICD=True (or commenting out this line since ICD=FALSE doesn't work)

I can use ANY combination of these 2 (4 options total Release/True,Release/False, Debug/True,Debug/False) and get a hex file to load and run standalone (e.g. ICD disconnnected)...AND I can use any combination of those and have the micro fail to start.

There is a third variable. As far as I can tell if you program your hex file from the Debugger Menu you will always get an install that won't boot without the ICD AND if you program a hex file using the Programmer Menu you will always get an install that will boot REGARDLESS of the above settings.
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sun Feb 12, 2017 1:49 pm     Reply with quote

A lot of this depends on which version of MPLAB is involved. There have been versions that did not work at all properly in this regard. Even one that wouldn't switch out of debug mode whatever you did....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group