18F2620 pbp3 example config please


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1

    Default 18F2620 pbp3 example config please

    Having never used any 18F chips I'm after an example config section of code to have a look at before I try to migrate my code to the new pic.

    My current 16F886 config looks like this

    Code:
    #CONFIG
     __CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_OFF & _PWRTE_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT 
    
     __CONFIG _CONFIG2, _WRT_OFF & _BOR21V
    #ENDCONFIG
    My 16F886 defines look like the below any obvious issues with those and 18F2620 pic. It should be pin compatible I believe.

    Code:
    DEFINE OSC 8            'Set PicBasic Pro processor speed to 8 Mhz   
    OSCCON = %01110101         'Internal 8 mhz Osc and stable 
    
    CM1CON0 = 0             'Comparator Off
    CM2CON0 = 0             'Comparator Off
    
    T1CON  = %00110000        '$30 = Prescaler 1:8, TMR1 OFF
        
    TRISA = %00001011         'SET PORTA0, A1 & A3 AS INPUTS, REST AS OUTPUTS
    TRISB = %00000000         'SET PORTB AS OUTPUTS
    TRISC = %10010000         'SET PORTC AS OUTPUTS EXCEPT PORT C4 & C7
        
    ANSEL  = %00000001        'SET INPUT AN0 AS ANALOG INPUT
    ANSELH = %00000000              'Disable PortB AD
        
    ADCON0 = %10000001        'SETUP ADC CONVERTER MODULE FOSC/32 & ENABLE ADC MODULE on AD0
    ADCON1 = %00000000        'SETUP ADC LEFT JUSTIFY SET REFV to VDD & VSS  
    
    DEFINE LCD_DREG PORTB         'PORTB is LCD data port
    DEFINE LCD_DBIT 0         'PORTB.0 is the data LSB
    DEFINE LCD_RSREG PORTC         'RS is connected to PORTC.0
    DEFINE LCD_RSBIT 0
    DEFINE LCD_EREG PORTC         'EN is connected to PORTC.1
    DEFINE LCD_EBIT 1
    DEFINE LCD_BITS 8         '8 lines of data are used
    DEFINE LCD_LINES 4         'It is a 4-line display
    DEFINE LCD_COMMANDUS 2000     'Use 2000uS command delay
    DEFINE LCD_DATAUS 50         'Use 50uS data delay
    
    DEFINE ADC_BITS 8              'Set number of bits in result
    DEFINE ADC_CLOCK 3          'Set Clock source (3 = rc)
    DEFINE ADC_SAMPLEUS 50         'Set sampling time in uS
       
    DEFINE CCP1_REG PORTC         'HPWM channel 1 pin Port C Backlight PWM Driver
    DEFINE CCP1_BIT 2         'HPWM channel 1 pin Bit 2
    Thanks Peter

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: 18F2620 pbp3 example config please

    Anyone with a config for a similiar 18F chip then? 2525, 4525, 4620?

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: 18F2620 pbp3 example config please

    I found this example so will keep trying.

    #CONFIG
    __CONFIG _CONFIG1H, _OSC_HS_1H & _FCMEN_OFF_1H & _IESO_OFF_1H
    __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
    __CONFIG _CONFIG3H, _CCP2MX_PORTC_3H & _PBADEN_OFF_3H & _LPT1OSC_OFF_3H & _MCLRE_ON_3H
    __CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _XINST_OFF_4L
    #ENDCONFIG

  4. #4
    Join Date
    Feb 2010
    Location
    USA, New England
    Posts
    164


    Did you find this post helpful? Yes | No

    Default Re: 18F2620 pbp3 example config please

    I did a migration of code from the 16F877 to the 18F452. They are *both* kind of older now...8^) If you thought it would be useful I can dig up the configurations for comparison. I never throw old code away, I just archive it. I've got versions of this particular ported code that go back to nearly the previous centrury.

    Best Regards,
    Paul
    The way to avoid mistakes is to gain experience. The way to gain experience is to make mistakes.

  5. #5


    Did you find this post helpful? Yes | No

    Default Re: 18F2620 pbp3 example config please

    If you have something it would be useful thanks.

  6. #6
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: 18F2620 pbp3 example config please

    The configs aren't so much different. If you use a programmer like an ICD2/3 or a PICKIT3, MPLAB will show you the options.

    The easiest thing to do would be to set it up in a way that makes sense and simply try it.
    Charles Linquist

  7. #7
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: 18F2620 pbp3 example config please

    The sub directory, "DEVICE_REFERENCE" of the PBP3 directory has an example with and all of the options listed.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts