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 works in debug mode but not running after programming

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mayur.k.vadukul



Joined: 07 Jul 2022
Posts: 45

View user's profile Send private message

Code works in debug mode but not running after programming
PostPosted: Thu Nov 20, 2025 7:31 am     Reply with quote

Hello,
I have been using the CCS compiler for a while and never had such issue.
I am using PIC18F66K22 device and have simple board of inputs and outputs. However, when I debug the code, it works well, i.e. when connecting the ICD U80 and debugging it by connecting ICP header, but when I compile and program as normal it does not give me results what I expect.
The logics are really simple AND and OR operation of 16 bit registers.
Any ideas? My header file for fuse is below:-

#fuses NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#fuses SOSC_DIG //Digital mode, I/O port functionality of SOSCI and SOSCO pins
#fuses INTRC_HP //LF-INTOSC in High-Power mode during Sleep
#fuses NOIESO //Internal External Switch Over mode disabled
#fuses NOFCMEN //Fail-safe clock monitor disabled
#fuses PLLEN //HW PLL enabled
#fuses HSM //High speed Osc, medium power 4MHz-16MHz
#fuses NOPUT //No Power Up Timer
#FUSES BROWNOUT //Reset when brownout detected
#FUSES BORV20 //Brownout reset at 2.0V
#FUSES BORM_HIGH //High-power BOR
#FUSES WDT //Watch Dog Timer
#FUSES WDT512 //Watch Dog Timer uses 1:8 Postscale
#FUSES VREGSLEEP //Ultra low-power regulator is disabled
#FUSES RTCOSC_INT //RTCC uses Internal 31KHz Oscillator as reference source
#fuses CCP2C1 //CCP2 input/output multiplexed with RC1
#FUSES MSSPMSK7 //MSSP uses 7 bit Masking mode
#FUSES MCLR //Master Clear pin enabled
#fuses NOSTVREN //Stack full/underflow will not cause reset
#FUSES BBSIZ2K //2K words Boot Block size
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOWRT //Program memory not write protected
#FUSES NOEBTR //Memory not protected from table reads
#FUSES NOEBTRB[/code]
_________________
MVadukul
Ttelmah



Joined: 11 Mar 2010
Posts: 19987

View user's profile Send private message

PostPosted: Thu Nov 20, 2025 9:26 am     Reply with quote

What is connected to the MCLR pin?
When in debug mode, this is controlled by the attached debugger. With
MCLR enabled, if this is not pulled up suitably, the code will not run
properly.....
mayur.k.vadukul



Joined: 07 Jul 2022
Posts: 45

View user's profile Send private message

MCLR is pulled up high
PostPosted: Thu Nov 20, 2025 9:33 am     Reply with quote

Ttelmah wrote:
What is connected to the MCLR pin?
When in debug mode, this is controlled by the attached debugger. With
MCLR enabled, if this is not pulled up suitably, the code will not run
properly.....

MCLR is pulled up.
_________________
MVadukul
Ttelmah



Joined: 11 Mar 2010
Posts: 19987

View user's profile Send private message

PostPosted: Thu Nov 20, 2025 10:22 am     Reply with quote

Look at your fuses.
Compiler in debug mode. Print the fuses at the end of the .LST file.
Then do the same in the normal mode.
When you debug several of the fuses are changed to allow debugging.
Look at what changes.
Also consider the power. How is the board powered?, and particularly how
is it grounded relative to other circuitry.
The debug plug supplies a ground and limited power. A fault with either
could still have the code working when the debugger is attached.
temtronic



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

View user's profile Send private message

PostPosted: Thu Nov 20, 2025 4:10 pm     Reply with quote

did you program in 'debug ' mode or 'release' mode ?
mayur.k.vadukul



Joined: 07 Jul 2022
Posts: 45

View user's profile Send private message

PostPosted: Fri Nov 21, 2025 4:13 am     Reply with quote

temtronic wrote:
did you program in 'debug ' mode or 'release' mode ?

This one is strange. Probably I have not explained. When my ICD U80 is connected and if I press "Debug" on the software, the program works exactly how it is supposed to be. But when I simply "program" and then disconnect ICD U80, it works randomly and does not work how it should.

I have got a Kanda Handheld programmer as well.

If I use the hex file created by other many of my projects on the Kanda programmer and load on to the board, it shows "Program Ok" message on its screen.

however, when I use this particular project's hex file and program using the Kanda Handheld programmer, it shows "Code Checksum". This implies the problem could be in the hex file created by the program. Which I don't seem to get it. Also, when I contacted Kanda, they said the message means the file is not correct.

I am in touch with the CCS directly as well, and they can't seem to understand. It is very simply code and no way near to the memory of the micro I am using.
_________________
MVadukul
Ttelmah



Joined: 11 Mar 2010
Posts: 19987

View user's profile Send private message

PostPosted: Fri Nov 21, 2025 11:19 am     Reply with quote

OK.
When you have finished debugging, you need to recompile the code, with
DEBUG not selected. The problem is when you debug, the code is compiled
for use in the debugger, not for normal running.
You have to recompile in normal run mode, before you program. Debug
code will not run without the debugger present.
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