Hello,
This if my first time using the 16f688 micro and I am having trouble getting it set up properly to print to my Lcd in a 4 bit mode. I looked in the archives and couldn't find anything that deals with Lcd's using the 16f688. I tried to use CMCON0 = 7 to shut off the comparators but when I compile I get an error saying syntax error?
The Lcd does turn on but the top line is just all dark black blocks with light gray blocks on the bottom line. The Led flashes properly in the Mainloop. Can anyone here help me understand what I'm doing wrong for the Lcd. Any suggestions would be greatly appreciated.
Thanks
jessey
Code:
'*******************************************************************************
'* Name : Blink Led *
'* Author : Jessey Montgomery *
'* Includes : *
'* Date : November 15/th 2006 *
'* Version : PicBasic Pro Ver 2.45, MPASM Ver 03.60, Using MicroCode Studio *
'* : 2.1.0.7, EPIC Version 2.46 beta programmer, PIC16F688-I/P 04470AY*
'*******************************************************************************
' --------------
' | 16f688 |
' VDD+ (--->) |1 14| (<---) VSS-
' | |
' RA5/TICKI/OSC1/CLKIN (<-->) |2 13| (<-->) RA0/AN0/C1IN+/ICSPDAT/ULPWU
' | |
'RA4/AN3/TIG/OSC2/CLKOUT (<-->) |3 12| (<-->) RA1/AN1/C1IN-/Vref/ICSPCLK
' | |
' RA3/MCLR/Vpp(--->) |4 11| (<-->) RA2/AN2/TOCKI/INT/C1OUT
' | |
' RC5/RX/DX (<-->) |5 10| (<-->) RC0/AN4/C2IN+
' | |
' RC4/C2OUT/TX/CX (<-->) |6 9| (<-->) RC1/AN5/C2IN-
' | |
' RC3/AN7 (<-->) |7 8| (<-->) RC2/AN6
' | |
' --------------
'------------------------------------------------------------------------------'
'------------- Clear Each Port Before Setting The TRIS Registers --------------'
'------------------------------------------------------------------------------'
Clear ' Set all ram registers to zero
PORTA = 0
PORTC = 0
'--------------------------- VSS VDD MCLR Ect. Pins ---------------------------'
' VDD + '(pin 1)
' VSS - '(pin 14)
'------------------- SET THE TRIS ------------------'
'-------------------- PORTA PINS --------------------'
TRISC.0 = 0 '(pin 10) ...Blue.................Lcd Data bit 4
TRISC.1 = 0 '(pin 9) ....White................Lcd Data bit 5
TRISC.2 = 0 '(pin 8) ....Green................Lcd Data bit 6
TRISC.3 = 0 '(pin 7) ...Orange...............Lcd Data bit 7
TRISC.4 = 0 '(pin 6) ...Orange/Black.........Lcd Register select
TRISC.5 = 0 '(pin 5) ...Blue/White...........Lcd Enable bit
'-------------------- PORTC PINS --------------------'
TRISA.0 = 1 '(pin 13) NOT USED
TRISA.1 = 0 '(pin 12) NOT USED
TRISA.2 = 1 '(pin 11) NOT USED
TRISA.3 = 1 '(pin 4) NOT USED
TRISA.4 = 1 '(pin 3) NOT USED
TRISA.5 = 1 '(pin 2) .......................Led
;==============================================
;
; Configuration Bits
;
;==============================================
' _FCMEN_ON EQU H'3FFF'
' _FCMEN_OFF EQU H'37FF'
' _IESO_ON EQU H'3FFF'
' _IESO_OFF EQU H'3BFF'
' _BOD_ON EQU H'3FFF'
' _BOD_NSLEEP EQU H'3EFF'
' _BOD_SBODEN EQU H'3DFF'
' _BOD_OFF EQU H'3CFF'
' _CPD_ON EQU H'3F7F'
' _CPD_OFF EQU H'3FFF'
' _CP_ON EQU H'3FBF'
' _CP_OFF EQU H'3FFF'
' _MCLRE_ON EQU H'3FFF'
' _MCLRE_OFF EQU H'3FDF'
' _PWRTE_OFF EQU H'3FFF'
' _PWRTE_ON EQU H'3FEF'
' _WDT_ON EQU H'3FFF'
' _WDT_OFF EQU H'3FF7'
' _LP_OSC EQU H'3FF8'
' _XT_OSC EQU H'3FF9'
' _HS_OSC EQU H'3FFA'
' _EC_OSC EQU H'3FFB'
' _INTRC_OSC_NOCLKOUT EQU H'3FFC'
' _INTRC_OSC_CLKOUT EQU H'3FFD'
' _EXTRC_OSC_NOCLKOUT EQU H'3FFE'
' _EXTRC_OSC_CLKOUT EQU H'3FFF'
' _INTOSCIO EQU H'3FFC'
' _INTOSC EQU H'3FFD'
' _EXTRCIO EQU H'3FFE'
' _EXTRC EQU H'3FFF'
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
'------------------------------------------------------------------------------'
'------------------------ Connections For Parallel Lcd ------------------------'
'-------------------------- To 16F688 Microprocessor --------------------------'
'--------------------------------- 4 Bit Mode ---------------------------------'
'------------------------------------------------------------------------------'
' LCD Wire
'Pin No. Color Symbol Function Connections To 16F688
'------ ------ ------ -------- ---------------------
' 1 Black Vss Ground ---------------Connect to -5V
' 2 Red Vdd +5V ------------------Connect to +5V
' 3 White / Black Vo LCD contrast 10K pot -Connect to center pad
' -other 2 pads to + & -
' 4 Orange / Black RS Register select ------Connect to pin (6) RC4
' 5 Red / White R/W Read / write ---------Connect to -5V
' 6 Blue / White E Enable ---------------Connect to pin (5) RC5
' 7 (not used) DB0 Data bit 0
' 8 (not used) DB1 Data bit 1
' 9 (not used) DB2 Data bit 2
' 10 (not used) DB3 Data bit 3
' 11 Blue DB4 Data bit 4 -----------Connect to pin (10) RC0
' 12 White DB5 Data bit 5 -----------Connect to pin (9) RC1
' 13 Green DB6 Data bit 6 -----------Connect to pin (8) RC2
' 14 Orange DB7 Data bit 7 -----------Connect to pin (7) RC3
DEFINE LCD_EREG PORTC 'Set LCD Enable port
DEFINE LCD_EBIT 7 'Set LCD Enable bit
ANSEL = %00000000 ' no analog inputs
Led VAR PORTA.5 ' (pin 2)
'----------------------- Set Initial Time Variables -------------------------
PAUSE 2000 'wait for the Lcd to stabilize, show version screen below
lcdout $fe,1," Blink "
lcdout $fe,$c0," Led "
pause 1000
GOTO Mainloop
Mainloop
HIGH Led
Pause 500
Low Led
Pause 500
goto Mainloop
Bookmarks