Re: STK500 Merge
Reply #8 –
[quote author="BrentBXR"]
What are these:
//set custom configuration for PIC 24F
_CONFIG2(FNOSC_FRCPLL & OSCIOFNC_ON &POSCMOD_NONE & I2C1SEL_PRI) // Internal FRC OSC = 8MHz
_CONFIG1(JTAGEN_OFF & GCP_OFF & GWRP_OFF & COE_OFF & FWDTEN_OFF & ICS_PGx1) //turn off junk we don't need
im guessing this is simulure to AVRs fusebits kind of (loosly) but software controlled. Like you can say I dont need this or that so disable to save power. or whatever.[/quote]
They are the config bits, similar to fuse settings used in an AVR uC. You don't have to set them in code, you can also use MPLAB IDE for setting them (from one of the menu options) but this method is preferred as you can just share the .c files and people usually do not care about project files (sometimes compiler and linker script folders are off), they might create their own and skip the ones shared.
[quote author="BrentBXR"]
My main question is; how can you make a PIC start up and ignore that _config and lets say I want to press a button that runs that _config command?
Is that possible?
What I need to do is in the BP v4's main() I need to do somthing like this sudo code:
ReadSetting = ReadSetting from eeprom(Address,default)
int main(void)
{
Var = ReadSetting(BP_START_MODE,0x00);
switch var
{
case 0x00:
break;
case 0x01:
Run(Those config settings);
Do not continue in normal BP mode;
Startup(STK500_MODE);
break;
default:
break;
}
Startup(NORMAL_MODE);
//we wont get here
}
not literally like that; but for example. How could I do that?[/quote]
That method you used is not possible as I know as config bits are compiled and set in the hex file at the respective page. But you can write to them in your code ie. bootloader code can write on itself and config bits (which brakes the bootloader and even the code you are uploading, so they either complain or do not allow this operation) and you reset the uC for it to work with the new settings. You can possibly do sth like this (means: check bootloader code), but you have to think about a way to store and load the old settings back when they are required.