View previous topic :: View next topic |
Author |
Message |
nilsener
Joined: 06 Dec 2005 Posts: 59
|
Large function causes program to fail [DONE] |
Posted: Mon Sep 03, 2007 8:52 am |
|
|
PCH 4.026
18F2620
Dear,
I have a large function with approx. 1000 code lines. All is working fine but after inserting an other approx. 15 code lines then the program fails. It compiles without problems and even if the function is not called from main(), the program fails. I got one watchdog reset after an other, that means the main() function is no more working. Restart_Wdt(); is already included. If I set NOWDT, I get watchdog reset, too!!!
Is it possible that the function with 1000 lines is too large and that this is the problem?
Thanks for any help!
nilsener
Last edited by nilsener on Tue Sep 04, 2007 9:17 am; edited 1 time in total |
|
|
Foppie
Joined: 16 Sep 2005 Posts: 138 Location: The Netherlands
|
|
Posted: Mon Sep 03, 2007 9:03 am |
|
|
Maybe it can be solved with a different compiler version.
The CCS site gives the following bugfix for release 4.031. This might have to do something with your problem.
Quote: | 4.031 Some WDT issues on chips with a WDTCON register are fixed |
Many forumusers find version 3.249 much better than the new v4 version. So that is also worth the try to get your hands on ;)
Hopefully this helps,
Cheers |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Sep 03, 2007 12:27 pm |
|
|
Quote: | If I set NOWDT, I get watchdog reset, too!!! |
How do you know this ? Have you put in code to call the restart_cause()
function, and then display the result ?
If you are truly getting a WDT timeout, then import the HEX file into
MPLAB and look at the Config bits. (Make sure MPLAB is set for the
18F2620 before you import the HEX file). Both of these settings are
done in the MPLAB Configure menu.
If MPLAB shows that the Config bits are set for "Watchdog Timer: OFF",
then you know it's got to be:
1. Your programmer doesn't work. It's not really programming the
Config bits, or not doing it correctly.
2. Your PIC is bad. It won't erase or program properly, or it won't
run properly.
3. You're programming a different HEX file than the one you think
you are. The real HEX file might be in a different directory,
and your programmer is aimed at the wrong directory.
4. You're not really getting a WDT timeout. It's something else that
looks like one. Use restart_cause() to check this.
5. You're using using a bootloader and it controls the fuses, not your
application program. It may have WDT enabled, and you can't
affect that at all from your CCS code. |
|
|
icesynth
Joined: 03 Sep 2007 Posts: 32 Location: Edmonton, Alberta
|
|
Posted: Mon Sep 03, 2007 5:32 pm |
|
|
What is the memory usage reported in your .lst file when you run the compiler? should look something like this:
Code: | Filename: main.lst
ROM used: 2388 words (29%)
Largest free fragment is 2048
RAM used: 232 (63%) at main() level
257 (70%) worst case
Stack: 7 worst case (5 in main + 2 for interrupts) |
I've seen that happen when there is not enough memory / stack space. _________________ Programming for the the real world.
--Chris Burchett
Sylver Technologies Inc. |
|
|
Guest
|
|
Posted: Tue Sep 04, 2007 2:40 am |
|
|
Dear icesynth,
I have this report in my lst file, do you think it is ok?:
CCS PCH C Compiler, Version 4.026, 31622 03-Sep-07 17:05
Filename: DFS73_001.lst
ROM used: 33026 bytes (50%)
Largest free fragment is 32506
RAM used: 781 (20%) at main() level
907 (23%) worst case
Stack: 10 worst case (6 in main + 4 for interrupts) |
|
|
Guest
|
|
Posted: Tue Sep 04, 2007 7:17 am |
|
|
PCH 4.014
18F2620
ICD2
MPLAB 7.22.00.00
Dear PCM Programmer,
thanks for your answer.
In the meantime I found, that the problem occurs if my program reaches exactly the size of >= 32768 byte = 50% of total program memory space. I use ICD2 and MPLAB 7.22.00.00. The Program Memory is programmed from 0x0 - 0x7FFF (32767 byte) even if the program is larger and so there will be a lack of code in the PIC. I think this is a strange error and I have no idea what to do. By the way, the reset is not coming from the watchdog. Restart_Cause() gives me a 15 that means MCLR_FROM_RUN but there is nothing like that.
Do you have any suggestions?
Best Regards
nilsener |
|
|
nilsener
Joined: 06 Dec 2005 Posts: 59
|
|
Posted: Tue Sep 04, 2007 7:30 am |
|
|
PostPosted: Tue Sep 04, 2007 7:17 am Post subject:
PCH 4.014
18F2620
ICD2
MPLAB 7.22.00.00
I found in MPLAB - Programmer-Settings-Program that the Program Memory is set to 0x0 - 0x7FFF (32kb). If I change to 0xFFFF (64kb) MPLAB changes it automatically back to 0x7FFF. How can I change to 0xFFFF?
Best Regards
nilsener |
|
|
Ttelmah Guest
|
|
Posted: Tue Sep 04, 2007 7:55 am |
|
|
'15', can have a variety of meanings, dependant on which bits CCS are actually checking, and whether some bits have been reset since the last boot.
The one that I'd be particularly suspicious about, is that a 'stack full' reset, also gives the same pattrn, but with the 'STKFUL' bit added. CCS, don't include this in their testing, so it'd be worth adding a check on this bit, and seeing if this might be the cause.
Best Wishes |
|
|
icesynth
Joined: 03 Sep 2007 Posts: 32 Location: Edmonton, Alberta
|
|
Posted: Tue Sep 04, 2007 8:25 am |
|
|
Try upgrading MPLAB to the latest version (7.60), I tried programming the device here, and had no trouble.
http://ww1.microchip.com/downloads/en/DeviceDoc/mp760a.zip _________________ Programming for the the real world.
--Chris Burchett
Sylver Technologies Inc. |
|
|
nilsener
Joined: 06 Dec 2005 Posts: 59
|
|
Posted: Tue Sep 04, 2007 9:17 am |
|
|
Dear,
problem solved. I have upgraded from 18F2520 to 18F2620 and forgot to change settings in MPLAB to 18F2620 and so it programs only to 0x7FFF (32kb) instead of 0xFFFF (64kb). I thought that it is enough to change it in my CCS Code. So it was an very easy problem and I feel shame.
Thank you all for your help!!!
nilsener |
|
|
icesynth
Joined: 03 Sep 2007 Posts: 32 Location: Edmonton, Alberta
|
|
Posted: Tue Sep 04, 2007 10:36 am |
|
|
We all have those days
I'm happy you got it fixed. _________________ Programming for the the real world.
--Chris Burchett
Sylver Technologies Inc. |
|
|
|