Help on lCD and PIC18F4550 setup


Closed Thread
Results 1 to 12 of 12

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Location
    Colorado
    Posts
    378


    Did you find this post helpful? Yes | No

    Default Re: Help on lCD and PIC18F4550 setup

    tacbanon,
    Not sure why you want to run at 48 MHz clock rate, but here is a routine that I have used at 8 MHz on a 18F4550 (and I know it works) on my EasyPic6 with PBP v2.6.
    Code:
    '****************************************************************
    '*  Name    : EasyPic_18F4550_DisplayDemo.pbp                  *
    '*  Author  : John R. Ellis                                     *
    '*  Date    : 11/28/2009                                        *
    '*  Version : 1.0                                               *
    '*  Notes   : Setup is for use on EasyPic6 development board    *
    '*          :                                                   *
    '*  Device  : 18F4550 installed in EasyPic6                     *
    '*  Memory  : 408 bytes of Program Memory required              * 
    '*  Ref:    :                                                   *
    '****************************************************************
    Define OSC 8
    ;--- 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_OSC1_PLL2_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
    INCLUDE "ALLDIGITAL.pbp"    ' Sets all registers for digital ops.
                                ' User must make sure the AllDigital.pbp file 
                                ' is in same directory location as this source
                                ' code before compiling.
        'DEFINE SHOWDIGITAL 1     ' When uncommented will show analog settings
                                ' in Assembler Results window.                        
        ' A/D & Comparators disabled for digital ops
            ' All of these statements should be commented out when using the
            ' INCLUDE "AllDigital.pbp" statement to set digital ops.
                'ADCON1 = %00001111
                'CMCON = 7
    ' Initialize Hardware 
    ' ------------------- 
        TRISA =%00000000 
        TRISB =%00000000 
        TRISC =%00000000 
        TRISD =%00000000 
        TRISE.0 = 0
        TRISE.1 = 0
        TRISE.2 = 0
        INTCON2.7 = 0
        
        '** DEFINE LCD Control Constants ** 
    '====================================
        L       CON 254           ' Control Byte ($FE) 
        Clr     CON 1             ' Clear the display 
        Line1   CON 128           ' Point to beginning of line 1 ($80) 
        Line2   CON 192           ' Point to beginning of line 2 ($C0) 
        
    ' LCD DEFINES FOR USE WIH 2x16 LCD INSTALLED IN EASYPIC6
    '=======================================================
        DEFINE LCD_DREG PORTB       ' Use PortB for LCD Data
        DEFINE LCD_DBIT 0           ' Use lower(4) 4 bits of PortB
                                    ' PORTB.0 thru PORTB.3 connects to
                                    ' LCD DB4 thru LCD DB-7 respectively
        DEFINE LCD_RSREG PORTB      ' PORTB for RegisterSelect (RS) bit
        DEFINE LCD_RSBIT 4          ' PORTB.4 pin for LCD's RS line
        DEFINE LCD_EREG PORTB       ' PORTB for Enable (E) bit
        DEFINE LCD_EBIT 5           ' PORTB.5 pin for LCD's E line
        DEFINE LCD_BITS 4           ' Using 4-bit bus
        DEFINE LCD_LINES 2          ' Using 2 line Display
        DEFINE LCD_COMMANDUS 2000   ' Command Delay (uS)
        DEFINE LCD_DATAUS 200       ' Data Delay (uS)
    'Main Loop
    '=========
    Main:
        Pause 1000                          ' Delay to let LCD start up 
        LCDOut L,CLR:Pause 50               ' Clear Display
        LCDOut L,Line1+2," TEST "           ' Display "TEST" on 1st line
        PAUSE 500
        LCDOut L,Line2+2,"..Power On.. !!"  ' Display "Power on" on 2nd line
        PAUSE 10000
        Goto Main                           ' Continue loop

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Help on lCD and PIC18F4550 setup

    Quote Originally Posted by jellis00 View Post
    tacbanon,
    Not sure why you want to run at 48 MHz clock rate,
    probably to use the USB... just an idea.

    To run @48MHz using a 4MHZ crystal, add those line at the top of your code. It's a copy/paste from my USBDemo
    Code:
        '
        '   Pic Configuration
        '   =================
        asm
        __CONFIG    _CONFIG1L, _PLLDIV_1_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L  
                                ;              ;                      ; USB clock source comes from the 96 MHz PLL divided by 2
                                ;              ; [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
                                ; No prescale (4 MHz oscillator input drives PLL directly)
    
    
        __CONFIG    _CONFIG1H, _FOSC_XTPLL_XT_1H & _FCMEN_OFF_1H & _IESO_OFF_1H 
                                ;                  ;               ; Oscillator Switchover mode disabled
                                ;                  ; Fail-Safe Clock Monitor disabled
                                ; XT oscillator, PLL enabled, XT used by USB
        __CONFIG    _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L  & _BORV_2_2L  & _VREGEN_ON_2L   
        __CONFIG    _CONFIG2H, _WDT_OFF_2H 
        __CONFIG    _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H 
        __CONFIG    _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L  & _XINST_OFF_4L & _DEBUG_OFF_4L 
        endasm
        DEFINE OSC 48
    now check the datasheet for the complete Config Fuse explanation. The OIscillator block on this one is not so simple.
    Last edited by mister_e; - 16th September 2011 at 12:55.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Jun 2011
    Location
    Philippines
    Posts
    223


    Did you find this post helpful? Yes | No

    Default Re: Help on lCD and PIC18F4550 setup

    Hi everyone, sorry for the late reply. I got it working now, of course with the help of mister_e's suggestion...thanks steve

Members who have read this thread : 0

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