I'm using an 18F2550, and having trouble figuring out the oscillator settings. Everything worked fine with 4Mhz Crystal, not so much with 20Mhz. I don't even get the crystal to work when looking at it with a scope. Ideally I need AD values sampled about 300 times in 10ms. I could go to 200-300 samples in 20 ms or slower, but what I have is too slow. With the 4Mhz XTAL I was getting about 30 samples in 20ms.

I'm using the bootloader, I programmed the PIC with the 20mhz.hex file using a programmer.
Then I try loading my code and I'm not getting any where. The boat loader was all working with 4Mhz XTAL.


I believe the issue is the CONFIG1H, or a multiplier that I'm not setting or uderstanding HS vs XT.

Here is all the configuration etc. I'm sure they can be optimized past my understanding, so comment on anything that should be different/better. The ADCON settings are at the bottom, I'll also include my A to D code, I'm doing it the recommended way from other posts I found here for A to D (not using the ADCIN). I'm not having any issue with the code, just including it so you have a more complete picture of what I'm doing.
Thanks,

Shane

Code:
DEFINE LOADER_USED 1

Define OSC 20

'Define LCD Port
  DEFINE LCD_DREG          PORTB  'Port used for LCD Data
  DEFINE LCD_DBIT          4      'First Pin connected to LCD DB4
  DEFINE LCD_RSREG         PORTB 'Port used for LCD RS line
  DEFINE LCD_RSBIT         3     'Pin used for LCD RS line
  DEFINE LCD_EREG          PORTB 'Port used for LCD E Reg
  DEFINE LCD_EBIT          0     'Pin used for LCD E line
  DEFINE LCD_BITS          4     'Four bit comm mode
  DEFINE LCD_LINES         2     '2 Line LCD
  DEFINE LCD_COMMANDUS     750    'Delay between sending LCD commands
  DEFINE LCD_DATAUS        5      'Delay time between data sent


DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
  DEFINE HSER_TXSTA 164 ' Enable brg, Enable transmit, BRGH = 1
  
  'DEFINE HSER_SPBRG 12  ' 19200 Baud @ 4MHz, 0.16%  pg 245 spbrg vals
  DEFINE HSER_SPBRG 64 ' 19200 Baud @ 20MHz, 0.16%  pg 245 spbrg vals
  DEFINE HSER_CLROERR 1 ' Clear overflow automatically

'Re-Configure default values from the PBP 18F2550.inc and MCSP/MPASM .inc
        'These are commented out in the .inc file

'__CONFIG  _CONFIG1H ,_FOSC_XT_XT_1H    ' Works with 4Mhz 
    '_CONFIG1H ,_FOSC_XTPLL_XT_1H           '20Mhz?
         
    asm
          __CONFIG  _CONFIG1H ,_FOSC_XTPLL_XT_1H
          __CONFIG  _CONFIG2L ,_BOR_ON_2L & _BORV_2_2L
     
        
    endasm

INCLUDE "DT_INTS-18.bas"     ; Base Interrupt System
    INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
    INCLUDE "Elapsed_INT-18.bas"  ; Elapsed Timer Routines
   
    ASM
INT_LIST  macro    ; IntSource,        Label,  Type, ResetFlag?
            INT_Handler    TMR1_INT,  _ClockCount,   PBP,  yes
            INT_Handler    TMR0_INT,  _ToggleLED1,   PBP,  yes
            INT_Handler    RX_INT,     _Check_Command, PBP, yes  
        endm
        INT_CREATE               ; Creates the interrupt processor
    ENDASM
         
@ INT_ENABLE    TMR1_INT     
@ INT_ENABLE    TMR0_INT
@ INT_ENABLE    RX_INT

OSCCON  = %01101100

ADCON0 = %00000000  'Setup
  ADCON1 = %00001010  'Port A0 Analog, rest to digital
                    
  ADCON2 = %10101000   'A/D Right Justified for 10 bit, 8 bit needs Left.
                      '12 Tad, Osc/2
  PortC = $00

Code:
'****************************CheckVoltage Sub*****************************
CheckVoltage:
MaxV1ADVal   = 0
MaxV2ADVal   = 0
MaxV3ADVal   = 0
For V1i = 0 to 19
    Gosub GetV1   
    Gosub GetV2 
    Gosub GetV3 
    'Pauseus 25
Next V1i
     
GoSub CheckState
  
Return
'***************************Get V1****************************************
GetV1:
   ADCON0 = %00000000 ' Select Channel AN0
   ADCON0.0 = 1       'Turn on A/D
   GoSub GetADVal
   V1ADVal.HighByte = ADRESH  'PLACES THE HIGH AND LOW BYTE
   V1ADVal.LowByte  = ADRESL   'INTO VAR CHAN0
   MaxV1ADVal= V1ADVAL Max MaxV1ADVal
Return
'***************************Get V2****************************************
GetV2:
   ADCON0 = %00000100 ' Select Channel AN1
   ADCON0.0 = 1       'Turn on A/D
   GoSub GetADVal
   V2ADVal.HighByte = ADRESH  'PLACES THE HIGH AND LOW BYTE
   V2ADVal.LowByte  = ADRESL   'INTO VAR CHAN0
   MaxV2ADVal= V2ADVAL Max MaxV2ADVal
Return
'***************************Get V3****************************************
GetV3:
   ADCON0 = %00001000 ' Select Channel AN2
   ADCON0.0 = 1       'Turn on A/D
   GoSub GetADVal
   V3ADVal.HighByte = ADRESH  'PLACES THE HIGH AND LOW BYTE
   V3ADVal.LowByte  = ADRESL   'INTO VAR CHAN0
   MaxV3ADVal= V3ADVAL Max MaxV3ADVal
Return
'***************************Get A/D Val*************************************
GetADVal:
   ADCON0.1 = 1 'Start Conversion
   WHILE ADCON0.1=1   'Waite for it to Complete
   WEND
RETURN