Hi Everyone
I just received my 16F737 from MELABS. I am using PICBASIC PRO 2.50C
I have used an external 4MHZ Crystal and 2 10uf Capacitors tied to ground.
I have also the PICBASIC PRO Book by Dougan Ibrahim and i used the LCD example which prints "Hello" Clear Screen and then "World" and it works perfectly fine.
I have also made the connections as assumed by PBP without defining ports. The ports connected are as below:
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 20K potentiometer (or ground)
************************************************** *****************
Now the issue i have is i used DEFINE statements to change the ports as below:
PicBasic program to demonstrate operation of an LCD in 4-bit mode
'
' LCD should be connected as follows:
' LCD PIC
' DB4 PortB.0
' DB5 PortB.1
' DB6 PortB.2
' DB7 PortB.3
' RS PortB.5 (add 4.7K pullup resistor to 5 volts)
' E PortB.4
' RW Ground
' Vdd 5 volts
' Vss Ground
' Vo 20K potentiometer (or ground)
' DB0-3 No connect
************************************************** **
And the code in picbasic pro as follows:
************************************************** **
Code:
include "bs1defs.bas"
' Define LCD registers and bits
Define LCD_DREG PORTB
Define LCD_DBIT 0
Define LCD_RSREG PORTB
Define LCD_RSBIT 5
Define LCD_EREG PORTB
Define LCD_EBIT 4
TRISB = 0
pause 10
loop: Lcdout $fe, 1 ' Clear LCD screen
pause 5
Lcdout "Hello" ' Display Hello
Pause 5 ' Wait .5 second
Lcdout $fe, 1 ' Clear LCD screen
pause 5
Lcdout "World"
Pause 5 ' Wait .5 second
Goto loop ' Do it forever
END
**************************************************************
Now the LCD pauses for a few seconds and there is a blinking cursor on Line 1, Column 1
When i connect back to the old configuration it works fine on the same code.
Also i am using a 4MHZ clock and a beginner in PBP and just switched from 89C51 Controller.
When i give 'PAUSE 5' it will wait for close to 5 seconds. Is there something that i have to mention about the close during flashing ? Or in code?
Also why will the LCD not function with this code. I rechecked and reconnected all the pins and all seems to be fine.
Please help to me find out what i am doing wrong.
Thanks to all in advance.
Bookmarks