PDA

View Full Version : Problems with LCD and 16F877A controler



mikkel
- 9th November 2010, 15:19
Hey

Hope there is somebody there can help us with some trouble with an LCD display

We are trying to write to a LCD display but the display doesn't show any signs of response. We have an LED to flash during the program to make sure it is running through it. We are using "PICDEM 2 PLUS DEMO BOARD 2006" as our platform for the controller and LCD, so the connection should be correct. As our microcontroller we have an 16F877A and as the programmer "MPLAB ICD 2"

Our codes is written in PicBasic

'*********Start***********
' Example program from manual to blink an LED connected to PORTB.0 about once a second

Define conf_word = 0x3f72
Define clock_frequency = 4
Alldigital

'Set LCD bus size (4 or 8 bits)
DEFINE LCD_BITS 4
'Set number of lines on LCD
DEFINE LCD_LINES 2
'Set command delay time in us
DEFINE LCD_COMMANDUS 1500
'Set data delay time in us
DEFINE LCD_DATAUS 44

'Set LCD Data port
DEFINE LCD_DREG PORTD
'Set starting Data bit (0 or 4) if 4-bit bus
DEFINE LCD_DBIT 0

'Set LCD Register Select port
DEFINE LCD_RSREG PORTA
'Set LCD Register Select bit
DEFINE LCD_RSBIT 3

'Set LCD RW Select port
DEFINE LCD_RWREG PORTA
'Set LCD RW Select bit
DEFINE LCD_RWBIT 2

'Set LCD Enable port
DEFINE LCD_EREG PORTA
'Set LCD Enable bit
DEFINE LCD_EBIT 1

Pause 1000

DEFINE LCD_READ_BUSY_FLAG = 1

TrisD = %00001011
TrisA = %00000000
PortD = %00000000

Pause 1000

TrisB.3 = 0 'turns off a LED

loop:
PortB.3 = 1 'turns on a LED

LCDOUT $FE,1
PAUSE 500
PortB.3 = 0 'turns off a LED
LCDOUT "Hello World"
PAUSE 1000

Goto loop ' Go back to loop and blink LED forever
End
'*********End***********

mackrackit
- 9th November 2010, 15:36
Define conf_word = 0x3f72
Set the configs in the *.inc file or in code space like described here.
http://www.picbasic.co.uk/forum/content.php?r=157-Presetting-Configuration-Fuses-(PIC-Defines)-into-your-Program


Define clock_frequency = 4
Should be
DEFINE OSC 4
if you are using a 4MHz clock


Alldigital
If you are trying to use DT's Alldigital it is an Include. For now try
CMCON=%00000111
ADCON1=%00000111
http://www.picbasic.co.uk/forum/showthread.php?t=561