[C18][ConfigurationBits] Reseted when Build ...

Post
Acceliis
New Member
2006/11/14 08:57:11
Hi world ! wink

From some months, I'm writting software for PIC18F4550 ( C compiled with C18 ) ... I'm writting a small kernel with LCD, I/O ...etc...

But from yesterday after some code add : nothing work as I want ... [:@] ...
( And I can't return to the "before" state to see what part cause this ... it's stupid, I know ... :( )

Every time I Build my software, all configuration bits are reseted ( I use MPLAB 7.50 ) ...

MPLab say :
Programming Target...
...Validating configuration fields
ICDWarn0013: Low Voltage Programming cannot be enabled when ICD 2 is used as a debugger.  Disable Low Voltage Programming?
ICD0200: Operation Aborted (Warning 12).
ICD0275:  Programming failed.
MPLAB ICD 2 Ready
Resetting Target
MPLAB ICD 2 Ready
ICDWarn0013: Low Voltage Programming cannot be enabled when ICD 2 is used as a debugger.  Disable Low Voltage Programming?

This was disabled in my configuration bits ... so they have been reseted ...

If I try to set configuration bits to correct values ... Warning came :
ICDWarn0015: Program memory has changed since last program operation?  Continue with Debug operation?
Running Target


But the software on the board isn't the correct one ...

Another important point : with a basic software, this don't happen ... like my software is the problem ... but what kind of code can cause this ?!

So ... I'm really lost ...

I think the problem can be with the stack, but I've enlarge it into the linker file  :
[...]
DATABANK   NAME=stack      START=0x60             END=0x1FF            PROTECTED
[...]
STACK SIZE=0x1A0 RAM=stack


( What happen on C stack overflow ?! )

Thanks a lot for reading this, and for your help Smile
post edited by Acceliis - 2006/11/15 03:07:45
Acceliis
New Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 04:09:28
More data about this :

I've re-created a new workspace+project and import all source files...

The problem still the same ...

I will try to find where the problem is by disabling some code parts ...
... really frustrating ... [:@]

Why the debugger cannot say where the problem is ... [sm=s14.gif]

... To be continued ...
eriklidgren
Super Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 05:14:01
Do you set the configuration bits in your code with #pragma config? Or with the Configuration Bits window in MPLAB IDE?
eriklidgren
Super Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 05:20:02
ORIGINAL: Acceliis


I think the problem can be with the stack, but I've enlarge it into the linker file  :
[...]
DATABANK   NAME=stack      START=0x60             END=0x1FF            PROTECTED
[...]
STACK SIZE=0x1A0 RAM=stack


( What happen on C stack overflow ?! )

Are you compiling with the Multi-bank stack model? Since your stack spans two banks.
 
ric
Super Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 05:27:42
ORIGINAL: Acceliis
...I think the problem can be with the stack, but I've enlarge it into the linker file  :
...

Why on earth do you think this is a problem with the stack? That's the last thing I'd try fiddling with.
You never reveal how you are setting the configuration bits. I suspect your problem is simply that you are not doing it correctly, using "#pragma" statements as erik suggested.
Acceliis
New Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 05:44:03
Do you set the configuration bits in your code with #pragma config? Or with the Configuration Bits window in MPLAB IDE?

No ... only in the MPLAB dialog ...

I will try to set this Configuratuion bits in the code ... but how could I do that ... any help for this #pragma
( Does anybody have done a small tools to generate a .h file with all #praga ? )

Just for my information :
This is not recommended ? ... Why ? ...
... If the dialog don't work, why Microchip don't remove it from MPLab or add a small Warning in the dialog ?!

ORIGINAL: ric
ORIGINAL: Acceliis
...I think the problem can be with the stack, but I've enlarge it into the linker file  :
...
Why on earth do you think this is a problem with the stack? That's the last thing I'd try fiddling with.
You never reveal how you are setting the configuration bits. I suspect your problem is simply that you are not doing it correctly, using "#pragma" statements as erik suggested.

Sorry for forgeting to say how Configuration bits are set ... done now ... ( only in MPLAB dialog ) ... probably the problem if I correctly follow you ...

Why a stack problem ? ... pink ... because I haven't any other idea ... but you are right : why the stack ? ...
( Where must I enable the multi bank stack system please ... if a day I need it ... )

In any case : thanks to all people who read this and a very big thanks to eriklidgren and ric for their answer.

Sebastien.
post edited by Acceliis - 2006/11/15 05:49:01
Acceliis
New Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 05:54:03
I have put a look at FAQ ... and found this document (C:\mcc18\doc\MPLAB-C18-Addendum.pdf) is available in the MC18 dir ...

I go read this ...

Thanks for help ! :)

NB: any idea on the "How to know the stack size requested by software ?"
eriklidgren
Super Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 06:14:09
( Where must I enable the multi bank stack system please ... if a day I need it ... )

Build Options dialog -> MPLAB C18 tab -> Category: Memory Model -> Stack Model: Set to Multi-bank model if your stack spans more than one bank.
 
NB: any idea on the "How to know the stack size requested by software ?"
You could fill the stack ram with a value, e.g. 0xAA, and then run your program in the simulator and see what locations change. That would give you an estimate on how much the stack grows.
Acceliis
New Member
RE: [C18][ConfigurationBits] Reseted when Build ... 2006/11/15 07:06:49
ORIGINAL: eriklidgren
Build Options dialog -> MPLAB C18 tab -> Category: Memory Model -> Stack Model: Set to Multi-bank model if your stack spans more than one bank.

Not a #pragma this time ?! ... this one work fine ??!! wink

You could fill the stack ram with a value, e.g. 0xAA, and then run your program in the simulator and see what locations change. That would give you an estimate on how much the stack grows.

Ok ... I will do that ... but simulate it isn't really possible since others modules connected to PIC will change a lot the PIC's work ... and so the stack used ... but I will find something in this spirit ... thanks !!!

Else : it's working !!! ... yes, with #pragma, my project looks work fine ( exept some strange bugs, but probably my fully fault this time ... )

... I have started a small tools to setup all Configuration bits like MPLAB's dialog, and write the coresponding .h file ... If this interreset anybody of you, it will be with pleasure I will post a free download link here ...

Another time : Thanks a lot eriklidgren and ric for all, and to the whole people here who help others ...

<< Long days and pleasant nights >>
Sebastien.
post edited by Acceliis - 2006/11/15 08:04:26