| View previous topic :: View next topic |
| Author |
Message |
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 45
|
| Code works in debug mode but not running after programming |
Posted: Thu Nov 20, 2025 7:31 am |
|
|
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
|
|
Posted: Thu Nov 20, 2025 9:26 am |
|
|
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
|
| MCLR is pulled up high |
Posted: Thu Nov 20, 2025 9:33 am |
|
|
| 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
|
|
Posted: Thu Nov 20, 2025 10:22 am |
|
|
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
|
|
Posted: Thu Nov 20, 2025 4:10 pm |
|
|
| did you program in 'debug ' mode or 'release' mode ? |
|
 |
mayur.k.vadukul
Joined: 07 Jul 2022 Posts: 45
|
|
Posted: Fri Nov 21, 2025 4:13 am |
|
|
| 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
|
|
Posted: Fri Nov 21, 2025 11:19 am |
|
|
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. |
|
 |
|