Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help me w/ LCD serial backpack project w/PicBasic Pro&16

Status
Not open for further replies.

Flamer1

New Member
i'm making a serial lcd backpack that can accept 1-wire serial input for any 16x2 hitachi chip lcd. i'm doing it using a 16f84 and using PicBasic Pro for the code. i wrote a quick code and it seems like it would work, but it seems too simple and right now i could have some extra opinions, especially because i don't have any lcd's to test it out with yet. here is my code:

Code:
'*==============================================================*
'*  Notes   : Serial backpack for 16F84                         *
'*          : 8-bit data bus on PORTB                           *
'*          : PORTA.0 is Enable bit                             *
'*          : PORTA.1 is Register Select bit                    *
'*                                                              *
'*          : for a 16x2 Line LCD                               *
'****************************************************************

DEFINE OSC 4

'Set LCD data port
DEFINE LCD_DREG PORTB
'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 1
'Set LCD enable port
DEFINE LCD_EREG PORTA
'Set LCD enable bit
DEFINE LCD_EBIT 0
'Set LCD bus size (4 or 8) bits
DEFINE LCD_BITS 8
'Set number of lines on LCD
DEFINE LCD_LINES 2
'Set command delay time in us
DEFINE LCD_COMMANDUS 2000
'Set data delay time in us
DEFINE LCD_DATAUS 50

DATAIN      Var PORTA.2
DATAOUT     Var PORTA.3
B0          Var Byte
POSITION    Var Byte

TRISA.0 = 1
TRISA.1 = 0

Lcdout $FE, 1
Pause 500           'Pause for initialization of LCD

START:
LINE1:
    Lcdout $FE, 1
    For POSITION = 0 to 15
RX:
    Serin2 DATAIN, 16780, 1, RX, [B0]   'read in ASCII data, timeout 1ms
    If B0 = 10 Then LINE2       'If line feed, goto next lcd line
TX:
    Lcdout $FE, $80+POSITION, B0       'output ASCII data to LCD
    Next POSITION

LINE2:    
    For POSITION = 0 to 15
RX2:
    Serin2 DATAIN, 16780, 1, RX2, [B0]
    If B0 = 10 Then LINE1       'If line feed, goto next lcd line
TX2:
    Lcdout $FE, $C0+POSITION, B0
    Next POSITION
    Goto START
End
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top