So one thing at a time, I want to get the LCD working again but on PortB. I've gone back to my code for the 16f627A and I want to get it working there before going back to the 16F88 and trying the ADC again.
I have used defines for LCDout so that I only use port B.
It compiles alright but when I run it on the PIC the LCD does not initialize. The light comes on, boxes are displayed (as the code used to do before initializing), the LED begins to toggle, but no change on the LCD.
The Code:
'************************************************* ***************
'* Name : LCDTest1.pbp *
'* Author : Greensasquatch *
'* Notice : Copyright (c) 2008 greensasquatch.ca *
'* : All Rights Reserved *
'* Date : 05/09/2008 *
'* Chip : PIC16F627A *
'* Version : 1.1 *
'* Notes : Send Hello World to a LCD on PORTB pins *
'* : blink a LED connected to RB6 as a status light *
'************************************************* ***************
'* PicBasicPro program to demonstrate *
'* operation of an LCD in 4-bit mode. *
'************************************************* ***************
'*
'* Connections are as follows:
'*
'* N/C -01-|####|-18- N/C
'* N/C -02-|####|-17- N/C
'* N/C -03-|####|-16- N/C
'* N/C -04-|####|-15- N/C
'* Gnd -05-|####|-14- V+
'* LCD Pin DB4 on RB0 -06-|####|-13- RB7, N/C
'* LCD Pin DB5 on RB1 -07-|####|-12- RB6, to red LED
'* LCD Pin DB6 on RB2 -08-|####|-11- RB5, E on LCD
'* LCD Pin DB7 on RB3 -09-|####|-10- RB4, RS on LCD
'*
'************************************************* ***************
INCLUDE "MODEDEFS.BAS"
@ DEVICE pic16F627A, INTRC_OSC_NOCLKOUT, MCLR_OFF
DEFINE LCD_DREG PORTB ' LCD data port
DEFINE LCD_DBIT 0 ' LCD data starting pin, RB0-RB3
DEFINE LCD_RSREG PORTB ' LCD register select port
DEFINE LCD_RSBIT 4 ' LCD "RS" register select pin
DEFINE LCD_EREG PORTB ' LCD enable port
DEFINE LCD_EBIT 5 ' LCD "E" enable pin
DEFINE LCD_BITS 4 ' LCD data bus size
DEFINE LCD_LINES 2 ' number of lines on the LCD
DEFINE LCD_COMMANDUS 1500 ' command delay in us
DEFINE LCD_DATAUS 44 ' data delay in us
'LED Connected to PortB.0 to circuit is doing something
LED var PORTB.6
CMCON = 7 'Turn off comparators
Pause 2000 ' Wait for LCD to startup
loop: toggle LED
Lcdout $fe, 1 ' Clear LCD screen
Pause 500 ' Wait .5 second
Lcdout "Greensasquatch" ' Display Greensasquatch on 1st line
Pause 500 ' Wait .5 second
toggle LED
Lcdout $fe,$c0,"Hello" ' move cursor to 2nd line, display Hello
Pause 1000 ' Wait 1 second
toggle LED
Lcdout $fe,$c0,"World" ' move cursor to 2nd line, display World
Pause 1000 ' Wait 1 second
toggle LED
Goto loop ' Do it forever
Bookmarks