PDA

View Full Version : Char. LCD and 18F452 on 20 MHz not work



samettin
- 27th July 2008, 16:36
Char. LCD and 18F452 on 4 MHz working, but on 20 MHz not work.

Please help me.




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"

mackrackit
- 27th July 2008, 16:53
Did you tell PBP that you are using 20 mhz

DEFINE OSC 20

samettin
- 27th July 2008, 17:06
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.

mackrackit
- 27th July 2008, 17:14
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?

samettin
- 27th July 2008, 17:26
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.

mackrackit
- 27th July 2008, 19:28
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.

skimask
- 27th July 2008, 20:05
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 :) )

samettin
- 27th July 2008, 22:23
My english is bad, sorry :D
With this code problem is finish. :)

Xtal = 20 MHz
Osc Config = HS

Need first code:


pause 1000
LCDOUT $FE,1
pause 500

after initialising lcd:


LCDOUT $FE,1,"HELLO WORLD"


But PAUSE and PAUSEUS working at value/5.

Example:

PAUSE 5000
working to 1 Second.

I edited in "pbppic18.lib" also PAUSE problem is finish.
with 4 MHz xtal pauseus macro.


;************************************************* ***************
;* 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.

samettin
- 27th July 2008, 22:33
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.

mackrackit
- 28th July 2008, 00:24
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.

skimask
- 28th July 2008, 02:26
My english is bad, sorry :D
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:

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.

samettin
- 28th July 2008, 09:59
Not understanding this statement.
Problem or No Problem?



No problem :)