I think I see what's going on. The file setdigitalio.bas defines a const 'DIG', and that's conflicting with the config settings
(I assume you have the 'config' statement after the 'include's)
Change the order of things... put the config statement in your main program before anything else, right after the 'device' and 'clock' statements, like so:
Code: Select all
device = 18F2321
clock = 8
config
OSC = INTIO2, // Internal oscillator block, port function on RA6 and RA7
FCMEN = OFF, // Fail-Safe Clock Monitor disabled
IESO = OFF, // Oscillator Switchover mode disabled
PWRT = OFF, // PWRT disabled
BOR = ON, // Brown-out Reset enabled in hardware only (SBOREN is disabled)
BORV = 3, // Minimum Setting
WDT = OFF, // WDT disabled (control is placed on the SWDTEN bit)
WDTPS = 32768, // 1:32768
CCP2MX = RC1, // CCP2 input/output is multiplexed with RC1
PBADEN = DIG, // PORTB<4:0> pins are configured as digital input channels on Reset
LPT1OSC = OFF, // Timer1 configured for higher power operation
MCLRE = ON, // MCLR pin enabled; RE3 input pin disabled
STVREN = ON, // Stack full/underflow will not cause Reset
LVP = OFF, // Single-Supply ICSP disabled
BBSIZ = BB256, // 256 Word
XINST = OFF, // Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
DEBUG = OFF, // Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
CP0 = OFF, // Block 0 not code-protected
CP1 = OFF, // Block 1 not code-protected
CPB = OFF, // Boot block not code-protected
CPD = OFF, // Data EEPROM not code-protected
WRT0 = OFF, // Block 0 not write-protected
WRT1 = OFF, // Block 1 not write-protected
WRTC = OFF, // Configuration registers (300000-3000FFh) not write-protected
WRTB = OFF, // Boot block not write-protected
WRTD = OFF, // Data EEPROM not write-protected
EBTR0 = OFF, // Block 0 not protected from table reads executed in other blocks
EBTR1 = OFF, // Block 1 not protected from table reads executed in other blocks
EBTRB = OFF // Boot block not protected from table reads executed in other blocks
include "intosc.bas"
#option DIGITALIO_INIT = true // automatically call SetAllDigital at startup
include "setdigitalio.bas"
That also allows the settings to be over-ridden by any of the files that you include since the last 'config' seen is the one that's used.
Another way to do this is to put the config settings in its own file with nothing else, and include that file in your main program-
Code: Select all
//config.bas
module config_18F2321
config
OSC = INTIO2, // Internal oscillator block, port function on RA6 and RA7
FCMEN = OFF, // Fail-Safe Clock Monitor disabled
IESO = OFF, // Oscillator Switchover mode disabled
PWRT = OFF, // PWRT disabled
BOR = ON, // Brown-out Reset enabled in hardware only (SBOREN is disabled)
BORV = 3, // Minimum Setting
WDT = OFF, // WDT disabled (control is placed on the SWDTEN bit)
WDTPS = 32768, // 1:32768
CCP2MX = RC1, // CCP2 input/output is multiplexed with RC1
PBADEN = DIG, // PORTB<4:0> pins are configured as digital input channels on Reset
LPT1OSC = OFF, // Timer1 configured for higher power operation
MCLRE = ON, // MCLR pin enabled; RE3 input pin disabled
STVREN = ON, // Stack full/underflow will not cause Reset
LVP = OFF, // Single-Supply ICSP disabled
BBSIZ = BB256, // 256 Word
XINST = OFF, // Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
DEBUG = OFF, // Background debugger disabled, RB6 and RB7 configured as general purpose I/O pins
CP0 = OFF, // Block 0 not code-protected
CP1 = OFF, // Block 1 not code-protected
CPB = OFF, // Boot block not code-protected
CPD = OFF, // Data EEPROM not code-protected
WRT0 = OFF, // Block 0 not write-protected
WRT1 = OFF, // Block 1 not write-protected
WRTC = OFF, // Configuration registers (300000-3000FFh) not write-protected
WRTB = OFF, // Boot block not write-protected
WRTD = OFF, // Data EEPROM not write-protected
EBTR0 = OFF, // Block 0 not protected from table reads executed in other blocks
EBTR1 = OFF, // Block 1 not protected from table reads executed in other blocks
EBTRB = OFF // Boot block not protected from table reads executed in other blocks
end module
That will isolate the config settings so they can't conflict with anything (the order of 'include's is still important though... you'd put 'include config.bas' first).
I recommend that you only put a 'config' statement AFTER the 'include's if you want to guarantee that it's the setting no matter what.
If in doubt, open the .asm file (F2) and you'll see the CONFIG settings at the very end.
btw - both the 2620 and 2321 are ancient devices... you'll pay a premium for them (if they're in stock).
With Microchip, typically the newer the device the cheaper, more features, and more available. They pretty much never obsolete a part... they just keep raising the price. For example, Digikey shows a DIP pkg 18F2321 is $4.91, while a DIP 18F24Q10 is $1.71. An 18F2620 is $9.24!!!!
In comparison, adjusting for the difference in memory sizes the 18F26Q10 is $1.91