Configuration bits and timing
Hi! I have two questions for you experts!
1) How can I include configuration bits such us: "__config _XT_OSC & _WDT_OFF & _PWRTE _ON & _CP_OFF" to my code? I am using a PIC18F2680.
If I just enter them it produces an error. I've tried with INCLUDE "18f2680" but then it pops out the PIC18F2680.inc file and it gives me the following errors:
WARNING: Unable to open INCLUDE file P18F2680.INC.
ERROR Line 16: ELSE without a matching IF..THEN. (LEDBLINK.pbp)
ERROR Line 24: ENDIF without a matching IF..THEN. (LEDBLINK.pbp)
ERROR Line 12: Syntax error. (18F2680.INC)
ERROR Line 13: Bad parameter to LIST command. (18F2680.INC)
ERROR Line 14: Syntax error. (18F2680.INC)
ERROR Line 17: Bad parameter to LIST command. (18F2680.INC)
ERROR Line 18: Bad parameter to LIST command. (18F2680.INC)
ERROR Line 20: Syntax error. (18F2680.INC)
ERROR Line 21: Syntax error. (18F2680.INC)
ERROR Line 22: Syntax error. (18F2680.INC)
ERROR Line 25: Bad parameter to LIST command. (18F2680.INC)
ERROR Line 26: Syntax error. (18F2680.INC)
ERROR Line 27: Syntax error. (18F2680.INC)
And another question. When I am using an external oscillator what should be the value for the Oscillator configuration bit? My code is suppossed to turn on and off an LED with a pause 1000. When I use XT and LP the pause is 4 seconds while when I use HS the pause is about 400msec...What am I doing wrong? I have defined the OSC as 20 since the oscillator I am using is 22.1184MHz...
Re: Configuration bits and timing
I think this thread would be the right place to ask this. I have a 18F26K80 that I'm trying to turn off the A/D on the A ports.
I tried the following;
ADCON0=$00 'switch the Analogue A/D pins to Digital I/O mode.
ADCON1=$00 'switch the Analogue A/D pins to Digital I/O mode.
ADCON2=$00 .
TRISA = $FF ' set port a to all inputs ' 28
TRISB = $00 'set port b to all outputs ' 29
TRISC = $FF 'set port c to all inputs ' 30
However, the inputs on the A ports are still ignored. What am I doing wrong??
Thanks
Re: Configuration bits and timing
Hi,
Open up the datasheet and take a look at the ADC section - especially the ANCON register. It says:
Quote:
The ANCONx registers are used to configure the operation of the I/O pin associated with each analog channel. Clearing an ANSELx bit configures the corresponding pin (ANx) to operate as a digital only I/O.
Cool device that, 12bit ADC with differential input, two internal references - hadn't noticed it before.
/Henrik.
Re: Configuration bits and timing
I've tried;
ANSEL = $00
ANSEL = 0
ANSEL0 = 0
and get "ERROR Line 30: Syntax error.30: Syntax error 30: Syntax error"
Any suggestions on the correct way to enter this setting in this new chip?
Re: Configuration bits and timing
I didn't see ANSEL in the p18f26k80.h file.
So I tried the following using the ANCON configuration registers and it seems to work;
ADCON0 = %00000000 ;P364 A/D CONTROL REGISTER 0
ADCON1 = %00000000 ;P365 A/D CONTROL REGISTER 1
ADCON2 = %00000000 ;P366 A/D CONTROL REGISTER 2
ODCON = %00000000 ;P179 PERIPHERAL OPEN-DRAIN CONTROL REGISTER
ANCON0 = %00000000 ;P369 A/D PORT CONFIGURATION REGISTER 0***
ANCON1 = %00000000 ;P369 A/D PORT CONFIGURATION REGISTER 1***
CM1CON = %00000000 ;P378 COMPARATOR CONTROL x REGISTER
CM2CON = %00000000 ;P378 COMPARATOR CONTROL x REGISTER
Thanks for pointing me in the right direction.
Re: Configuration bits and timing
That's because there is no ANSEL register in the 26K80. The register is called ANCONx.
/Henrik.