Char. LCD and 18F452 on 20 MHz not work


Closed Thread
Results 1 to 12 of 12
  1. #1
    Join Date
    Jul 2008
    Posts
    6

    Default Char. LCD and 18F452 on 20 MHz not work

    Char. LCD and 18F452 on 4 MHz working, but on 20 MHz not work.

    Please help me.

    Code:
    define LCD_BITS 4
    DEFINE LCD_DREG PORTD
    DEFINE LCD_DBIT 4
    DEFINE LCD_RSREG PORTC
    DEFINE LCD_RSBIT 6
    DEFINE LCD_EREG PORTC
    DEFINE LCD_EBIT 7
    DEFINE LCD_LINES 4
    DEFINE LCD_COMMANDUS 2000
    DEFINE LCD_DATAUS 50
    
    
    LCDOUT $FE,1,"HELLO WORLD"

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


    Did you find this post helpful? Yes | No

    Default

    Did you tell PBP that you are using 20 mhz

    DEFINE OSC 20
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Did you tell PBP that you are using 20 mhz

    DEFINE OSC 20
    Yes mackrackit.
    And OSC = HS
    But PBP not compile 18f452 to hex, MPASM compiling to hex. And MPASM compiling on (default) 4 MHz only.
    Last edited by samettin; - 27th July 2008 at 17:14.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by samettin View Post
    Yes mackrackit.

    But PBP not compile 18f452 to hex, MPASM compiling to hex. And MPASM compiling on (default) 4 MHz only.
    MPASM is required for 18s.
    How do you know it is doing 4 MHz? Did you change the congig (*.inc) to HS?
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Jul 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    I m sorry, i changed my message

    I did change OSC to HS.

    LCD vorking with 18F452 on 4 MHz xtal and osc config = XT.

    Problem is, if PLL enable with 4 MHz XTAL, or 20 MHz with osc config=HS then.
    Last edited by samettin; - 27th July 2008 at 17:29.

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


    Did you find this post helpful? Yes | No

    Default

    Could you post all of the code and config, not what you think the configs are set for, but a copy paste of the *.inc.
    Dave
    Always wear safety glasses while programming.

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by samettin View Post
    Problem is, if PLL enable with 4 MHz XTAL, or 20 MHz with osc config=HS then.
    Might want to also keep in mind that the PLL doesn't work above 10Mhz. The max speed of the PIC is 40Mhz (10 x 4xPLL). Try as you might, you won't get the PIC to run at 160Mhz! (It would be nice, but it won't work )

  8. #8
    Join Date
    Jul 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    My english is bad, sorry
    With this code problem is finish.

    Xtal = 20 MHz
    Osc Config = HS

    Need first code:
    Code:
    pause 1000
    LCDOUT $FE,1
    pause 500
    after initialising lcd:
    Code:
    LCDOUT $FE,1,"HELLO WORLD"
    But PAUSE and PAUSEUS working at value/5.

    Example:
    Code:
    PAUSE 5000
    working to 1 Second.

    I edited in "pbppic18.lib" also PAUSE problem is finish.
    with 4 MHz xtal pauseus macro.
    Code:
    ;****************************************************************
    ;* PAUSEUS    : Pause n microseconds at 4MHz                    *
    ;*                                                              *
    ;* Input      : R0 + 1, W = microseconds                        *
    ;* Output     : None                                            *
    ;*                                                              *
    ;* Notes      : minimum 19us                                    *
    ;****************************************************************
    
          if (OSC == 4)
      LIST
    PAUSEUS clrf	R0 + 1		; 1
    PAUSEUSL addlw	-23		; 1 Subtract overhead
                 movwf   R0                        ; 1
    	movlw	-4		; ********changed -1 to -4***********
    	bnc	pauseush	             ; 1 / 2
    	nop			; 1
    pauseusloop CLRWDT?NOP		; 1
    	addwf	R0, F		; 1
    	bc	pauseusloop	; 1 / 2
    	nop			; 1
    pauseush addwf	R0, F		; 1
    	decf	R0 + 1, F	; 1
    	bc	pauseusloop	; 1 / 2
    	btfsc	R0, 0		; 1 / 2
    	bra	$ + 2		; 2 / 0
    	btfss	R0, 1		; 1 / 2
    	bra	pauseusdone	; 2 / 0
    	bra	$ + 2		; 0 / 2
    	nop			; 0 / 1
    pauseusdone return		; 2 + 3 (call + setup)
      NOLIST
          endif
    Thanks for your interesting.

    Best regards.
    Last edited by samettin; - 27th July 2008 at 22:28.

  9. #9
    Join Date
    Jul 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Might want to also keep in mind that the PLL doesn't work above 10Mhz. The max speed of the PIC is 40Mhz (10 x 4xPLL). Try as you might, you won't get the PIC to run at 160Mhz! (It would be nice, but it won't work )
    160Mhz?
    Sorry i dont see.

    With 4 MHz and PLL 4X4 = 16 MHz.
    20 MHz is without PLL. This osc conf. is XT.

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


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by samettin View Post
    160Mhz?
    Sorry i dont see.

    With 4 MHz and PLL 4X4 = 16 MHz.
    20 MHz is without PLL. This osc conf. is XT.
    Thought you said it was set for HS. XT will not work. Me thinks.
    Dave
    Always wear safety glasses while programming.

  11. #11
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by samettin View Post
    My english is bad, sorry
    It's good enough. Don't worry about it...

    With this code problem is finish.
    Not understanding this statement.
    Problem or No Problem?

    But PAUSE and PAUSEUS working at value/5.
    Example:
    Code:
    PAUSE 5000
    working to 1 Second.
    Which leads me to believe that either you config statements are 'taking effect' or your PIC is actually running on the internal 4Mhz clock vs. the external 20Mhz oscillator.

  12. #12
    Join Date
    Jul 2008
    Posts
    6


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    Not understanding this statement.
    Problem or No Problem?
    No problem

Similar Threads

  1. 18F452 and 8-bit LCD
    By exelanoz in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th December 2009, 07:57
  2. with 40 MHZ osc serin2 not work
    By Pedro Santos in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th August 2006, 22:56
  3. Replies: 5
    Last Post: - 5th February 2006, 16:51
  4. How do I get DATA @ to work with a 18F452?
    By jessey in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 2nd February 2006, 10:35
  5. Why doesn't my code for 18f452 work on 18f252?
    By senojlr in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 23rd December 2005, 02:42

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