Bert, your idea of putting CONFIG statement in an include file is a great one that I want to implement in all of my codes. However, I tried it in one of my working application codes and the code stopped working afterwards. In hopes you can tell me why here is what I did:
1. I created a new .inc file by copying and pasting the following statements into a new code file and saving it as a .inc file in the PBP folder where all of my codes are in a subfolder to the PBP folder.
INCLUDE "18F2550_4550_CONFIGS.inc" ' Setup CONFIGS for MCU
;--- if you un-comment these, you must comment the ones in the .inc file--
;ASM ; 18F2550/4550, 8mhz crystal
;__CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
;__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
;__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
;__CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital
;__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
;ENDASM
2. I then replaced the CONFIG statements in my application code with the follwoing statement in which I commented out all of the original CONFIG statements:
Include "18F2550_4550_CONFIGS.inc"
;--- if you un-comment these, you must comment the ones in the .inc file--
;ASM ; 18F2550/4550, 8mhz crystal
; __CONFIG _CONFIG1L, _PLLDIV_2_1L & _CPUDIV_OSC4_PLL6_1L & _USBDIV_2_1L
; __CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
; __CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
; __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
; __CONFIG _CONFIG3H, _PBADEN_OFF_3H ; PortB resets as digital
; __CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
;ENDASM
3. The modified application code compiles and assembles OK and appears to run, but it no longer works correctly and I can't see why.
4. If I comment out the new .inc statement and uncomment the _CONFIG statements it works OK again.
Can you tell me what I am doing wrong?
Thanks, John Ellis
Bookmarks