Check the data sheet for this PIC. Several PORTB pins are analog intputs at power-up, and
you'll need to write to OSCCON to configure it for 8MHz internal.
The default value in OSCCON at reset is for 1MHz.
Check the data sheet for this PIC. Several PORTB pins are analog intputs at power-up, and
you'll need to write to OSCCON to configure it for 8MHz internal.
The default value in OSCCON at reset is for 1MHz.
I have defined Port B as output port in my code by using TRISB=0.
And by using the command:
@_CONFIG_CONFIG1H_OSC_INTIO67_1H
the internal oscillator is working fine at 8 MHz.
The LCD is now displaying text messages, but when I try to display a numerical value of a variable or a constant, it doesnt show anythin as the screen remains blank.
Please Help !!
DEFINE OSC 8
'******Setting up the LCD display******
DEFINE LCD_DREG PORTB
DEFINE LCD_DBIT 4
DEFINE LCD_RSREG PORTB
DEFINE LCD_RSBIT 0
DEFINE LCD_EREG PORTB
DEFINE LCD_EBIT 1
DEFINE LCD_BITS 4
DEFINE LCD_LINES 2
DEFINE LCD_COMMANDUS 2000
DEFINE LCD_DATAUS 50
@_CONFIG_CONFIG1H_OSC_INTIO67_1H
TRISB=0 'Set Port B as output
PAUSE 1000
LCDOUT $FE, 1
LCDOUT "PIC - LCD Test "
LCDOUT $FE, $C0
STOP
Hello, you need to use DEC command, for example:
b0 var byte
b0=100
loop:
LCDOut $fe, 1
LCDOut "LCD TEST" 'Display line1
LCDOut $fe, $c0 'Move to line 2
LCDOut Dec b0 'Display b0 on LCD
Pause 500 'Wait .5 second
goto loop
end
OK. Sorry. You're probably right, but give this a shot just for the heck of it.;o}
1. Edit your 18F4525.INC file in your PBP directory. Change this line;
__CONFIG _CONFIG1H, _OSC_XT_1H
to this; __CONFIG _CONFIG1H, _OSC_INTIO67_1H
Save the file.
Note this line: __CONFIG _CONFIG3H, _PBADEN_OFF_3H saves you from having to
manually disable A/D for several PORTB pins. Just FYI.
2. Change your code to something like this;
Does it work now?Code:DEFINE OSC 8 '******Setting up the LCD display****** DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 4 DEFINE LCD_RSREG PORTB DEFINE LCD_RSBIT 0 DEFINE LCD_EREG PORTB DEFINE LCD_EBIT 1 DEFINE LCD_BITS 4 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 2000 DEFINE LCD_DATAUS 50 '@_CONFIG_CONFIG1H_OSC_INTIO67_1H ; this does nothing & it is not a command TRISB=0 'Set Port B as output OSCCON = %01110010 a VAR BYTE Loop: LCDOUT $FE,1,"PIC - LCD Test " PAUSE 1000 FOR a = 0 TO 255 LCDOUT $FE, $C0," A = ", #a PAUSE 1000 NEXT a GOTO Loop END
Bookmarks