Brian,
I don't use bootloaders very often, so this isn't the way I normally do things.
But I thought I'd give some food for thought on setting configs with either a bootloader or ICSP on 18F's.
If the bootloader is being used. It includes the Run-Time Config module from ...Code:ASM ;--[CONFIG1H]-------------------------------------------------- CFG_1H = _OSC_HSPLL_1H ; Oscillator CFG_1H = CFG_1H & _FCMEN_OFF_1H ; Fail-safe Clock Monitor CFG_1H = CFG_1H & _IESO_OFF_1H ; Int/Ext Osc Switchover ;--[CONFIG2L]-------------------------------------------------- CFG_2L = _PWRT_ON_2L ; Power-ON Timer CFG_2L = CFG_2L & _BOREN_ON_2L ; Brown Out CFG_2L = CFG_2L & _BORV_2_2L ; Brown Out voltage ;--[CONFIG2H]-------------------------------------------------- CFG_2H = _WDT_ON_2H ; Watch Dog Timer CFG_2H = CFG_2H & _WDTPS_512_2H ; WDT Prescaler ;--[CONFIG3H]-------------------------------------------------- CFG_3H = _MCLRE_ON_3H ; Master Clear Reset CFG_3H = CFG_3H & _LPT1OSC_OFF_3H ; Low Power TMR1 Osc CFG_3H = CFG_3H & _PBADEN_OFF_3H ; PORTB Analog CFG_3H = CFG_3H & _CCP2MX_PORTC_3H ; CCP Multiplexer ;--[CONFIG4L]-------------------------------------------------- CFG_4L = _STVREN_ON_4L ; Stack Over/Under Reset CFG_4L = CFG_4L & _LVP_OFF_4L ; Low Voltage Programming CFG_4L = CFG_4L & _XINST_OFF_4L ; Extended Instructions CFG_4L = CFG_4L & _DEBUG_OFF_4L ; Hardware Debugger ;-------------------------------------------------------------- ifdef LOADER_USED ; If bootloader is used #include "RTconfig.inc" ; change Configs at runtime WriteConfig?CC _CONFIG1H, CFG_1H WriteConfig?CC _CONFIG2L, CFG_2L WriteConfig?CC _CONFIG2H, CFG_2H WriteConfig?CC _CONFIG3H, CFG_3H WriteConfig?CC _CONFIG4L, CFG_4L else ; If bootloader NOT used __CONFIG _CONFIG1H, CFG_1H ; set __configs in program __CONFIG _CONFIG2L, CFG_2L __CONFIG _CONFIG2H, CFG_2H __CONFIG _CONFIG3H, CFG_3H __CONFIG _CONFIG4L, CFG_4L endif ENDASM ;----------------------------------------------[ END Configs]--
http://www.picbasic.co.uk/forum/showthread.php?t=4093
Then sets the configuration manually at run-time.
The module checks the configs on every reset, but only writes them if they are different.
If the bootloader is Not being used, it saves space by not including the Run Time Config module and puts the __CONFIG's in the program like normal.
Be carefull when changing Oscillator settings!
If you set a mode that does not provide a system clock, or gives a clock at a frequency that the bootloader does not expect, ...
You will have to re-Flash the bootloader to make it work again.
You may even want to comment out the WriteConfig?CC _CONFIG1H line, just to make sure it doesn't get changed.
HTH,




Bookmarks