View previous topic :: View next topic |
Author |
Message |
randy.shaffer
Joined: 21 Mar 2018 Posts: 69
|
Stuck in debug again with 18F45K22 [solved] |
Posted: Tue Apr 29, 2025 1:08 pm |
|
|
Code: | #include <18F45K22.h>
#use delay(internal=32MHz)
void main(void)
{
while(TRUE)
{
output_high(PIN_B4);
delay_ms(500);
output_low(PIN_B4);
delay_ms(500);
}
} |
Everything was working fine until I switched to the debugger, now it ONLY works in the debugger. I tried #device ICD=, but no change. Any guidance is greatly appreciated. Compiler is 5.119, programmer is ICD-U64.
Last edited by randy.shaffer on Wed Apr 30, 2025 9:41 am; edited 1 time in total |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9462 Location: Greensville,Ontario
|
|
Posted: Tue Apr 29, 2025 3:23 pm |
|
|
In MPLAB, you have to compile in 'release' mode to get PICs to work in the 'real world'. If you compile in 'debug', there's extra stuff added.....
Others with more modern compilers and IDEs will know.. |
|
 |
randy.shaffer
Joined: 21 Mar 2018 Posts: 69
|
|
Posted: Tue Apr 29, 2025 3:35 pm |
|
|
Thank you, but I'm using the CCS compiler. The IDE seems stuck in debug. I've even tried with another MCU on another project. |
|
 |
temtronic
Joined: 01 Jul 2010 Posts: 9462 Location: Greensville,Ontario
|
|
Posted: Tue Apr 29, 2025 3:42 pm |
|
|
Ok the IDE has to have an 'option' to 'build' in 'debug ' or 'release' mode.
I'm a dinosaur that still uses PCM through MPLAB.... |
|
 |
randy.shaffer
Joined: 21 Mar 2018 Posts: 69
|
|
Posted: Tue Apr 29, 2025 3:50 pm |
|
|
Thank you again, but that is the rub, there is no release-mode option (that I can find). |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19803
|
|
Posted: Wed Apr 30, 2025 12:50 am |
|
|
It's controlled by having he debug tab open.
If you select 'debug', it'll open this tab, and ask if you want to recompile.
Once you have done this, so long as this tab remains open, it'll always
compile in debug mode.
Top right corner. Red cross, closes this tab. Then select 'recompile', and it'll
compile without debug.
However 'caveat'. If you have the line ICD=xx in your code it'll always
compile in debug mode. Remark this line out, and the behaviour becomes
controlled by the tab.
Personally I never add the ICD= line to the code. Just have the ICSP=xx
lie to control which pins are used, and let the compiler control the debug
as outlined above. |
|
 |
randy.shaffer
Joined: 21 Mar 2018 Posts: 69
|
|
Posted: Wed Apr 30, 2025 9:17 am |
|
|
Thank you for the reply, but the Debug tab is not open, nor is the ICD = TRUE in the code. I normally don't add the 'ICD = ' as well since the compiler prompts for it when Debug is selected. I contacted CCS, here is the response:
Quote: | Compare the fuses at the bottom of the LST file when you compile for production and when you
compile for debugging. The problem may be a fuse that is changed to be compatible for debugging.
It is also possible a pullup in the ICD makes a difference in the way the program runs. |
Here is a snippet of the LST file for the fuses:
Configuration Fuses:
Word 1: E800 INTRC_IO NOPLLEN PRIMARY_ON FCMEN IESO
Word 2: 3C1E PUT BROWNOUT BORV19 NOWDT WDT32768
Word 3: BF00 CCP2C1 PBADEN CCP3B5 HFOFST TIMER3C0 CCP2D2 MCLR
Word 4: 0081 STVREN NOLVP NOXINST NODEBUG
Word 5: C00F NOPROTECT NOCPB NOCPD
Word 6: E00F NOWRT NOWRTC NOWRTB NOWRTD
Word 7: 400F NOEBTR NOEBTRB
I've tried using the U64 and U80 to no avail. I have tried re-installing the compiler. I have tried programming a different MCU on a different project and now that MCU doesn't work. |
|
 |
Ttelmah
Joined: 11 Mar 2010 Posts: 19803
|
|
Posted: Wed Apr 30, 2025 9:25 am |
|
|
OK.
That is not compiling in debug mode.
How is your MCLR connected????.
Key is the debugger pulls this up. Your fuses have MCLR selected, so this
has to be pulled up. |
|
 |
randy.shaffer
Joined: 21 Mar 2018 Posts: 69
|
|
Posted: Wed Apr 30, 2025 9:40 am |
|
|
MCLR is connected to +5 through a 10k resistor. However, I just updated the CCSLOAD firmware from 3.61 to 3.62 and the problem appears to be solved. |
|
 |
|