LCD works at 4MHz, but not 12 or 16MHz


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37

    Default LCD works at 4MHz, but not 12 or 16MHz

    Hello helpful people!

    I wrote (well..copied, pasted, and hacked) a program to simply spit out some messages to a LCD. It works great with the internal or external 4MHz clock. But when I try to use a faster clock, there are some good characters, but also some garbage displayed on the LCD.

    I'd like to increase the clock speed because eventually I would like to interface with a RFID reader Ic where the Rx data transmission rate is 15625 baud async. So I picked some 12MHz and 16MHz resonators to play with.

    The LCD is a 14 pin, 16x4 character LCD from OPTREX. I assume it's compatable with the common Hitachi LCD controller. The only wierd thing about the LCD was that when I used the "move cursor to beginning of x line" commands, the cursor was a couple of spaces off, so I played with it until it looked right.

    Here is my code, it's for a 16F628A, using PBP in MPLAB and MPASM

    Code:
     
    ' PicBasic program to demonstrate operation of an LCD in 4-bit mode
    '
    ' LCD should be connected as follows:
    '       LCD     PIC
    '       DB4     PortA.0
    '       DB5     PortA.1
    '       DB6     PortA.2
    '       DB7     PortA.3
    '       RS      PortA.4 (add 4.7K pullup resistor to 5 volts)
    '       E       PortB.3
    '       RW      Ground
    '       Vdd     5 volts
    '       Vss     Ground
    '       Vo       (ground)
    '       DB0-3   No connect
    
        '
        '    PIC Configuration
        '    =================
        '    @ __CONFIG  _INTRC_OSC_NOCLKOUT & _MCLRE_OFF  &  _LVP_OFF & _WDT_OFF & _PWRTE_ON  & _BODEN_ON
      
         @ __CONFIG  _XT_OSC & _MCLRE_OFF  &  _LVP_OFF & _WDT_OFF & _PWRTE_ON  & _BODEN_ON  
    
        '
        '    Hardware configuration
        '    ======================
    
    	DEFINE OSC 12
        CMCON=7                    ' disable internal comparator
        TRISA=0                    ' Set all PORTA capable i/o to output
        TRISB=0                    ' Set all PORTB i/o to output
        
        '
        '    Hardware initialisation
        '    =======================
    
    DEFINE LCD_LINES 4
    
        Pause 1000                 '1 second for LCD initialisation
        LCDOUT $FE, 1			   ' clear LCD
        '
    
    Start:
        LCDOUT $FE,2,  "     WELCOME    "
        LCDOUT $FE,$C0,"     TO THE     "
        LCDOUT $FE,$90,"   ELECTRICAL   "
        LCDOUT $FE,$D0,"   DEPARTMENT   "
    
    
       Pause 3000    
    
    
        LCDOUT $FE,2,  "                "
        LCDOUT $FE,$C0,"  Please have   "
        LCDOUT $FE,$90,"   a  seat      "
        LCDOUT $FE,$D0,"                "
    
    
    
       Pause 3000  
    
        LCDOUT $FE,2,  "   someone will "
        LCDOUT $FE,$C0,"    be  with    "
        LCDOUT $FE,$90,"       you      "
        LCDOUT $FE,$D0,"     shortly    "
    
    
       Pause 3000  
    
    
    
        Goto Start

    Thanks for looking.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Look in the PBP manual in the LCDOUT section for commandus and dataus delays and try increasing them a bit.
    Also, are you changing your oscillator from XT to HS?

  3. #3
    Join Date
    Jun 2008
    Location
    Milwaukee, WI
    Posts
    37


    Did you find this post helpful? Yes | No

    Smile awww yeah

    Its working now. That was it. I added this:

    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 100

    thank you so much, this forum is so helpful.

    ...yeah, I had to change XT_osc to HS_osc in order to get my 16MHz resonator to work at all. 12MHz seems to be ok with just XT_osc. Is there a frequency where you should start to use HS_osc?

    thanks again.

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Max Power View Post
    ...yeah, I had to change XT_osc to HS_osc in order to get my 16MHz resonator to work at all. 12MHz seems to be ok with just XT_osc. Is there a frequency where you should start to use HS_osc?
    It's in the datasheets for your particular PIC.

Similar Threads

  1. 16f688 LCD what have I done wrong
    By spitfiredriver in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 8th August 2009, 19:54
  2. LCD R/S works on Port A but not Port B
    By TDonBass in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 10th February 2009, 12:41
  3. Play with LCD on PICDEM
    By The IceMan in forum mel PIC BASIC
    Replies: 5
    Last Post: - 22nd August 2008, 16:56
  4. Need help with LCD number display.
    By Steve Matson in forum mel PIC BASIC
    Replies: 8
    Last Post: - 26th June 2007, 23:07
  5. Real Time Clock & Eeprom
    By smart_storm in forum General
    Replies: 8
    Last Post: - 17th February 2006, 19:03

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