Hello helpful people!
I wrote (well..copied, pasted, and hacked) a program to simply spit out some messages to a LCD. It works great with the internal or external 4MHz clock. But when I try to use a faster clock, there are some good characters, but also some garbage displayed on the LCD.
I'd like to increase the clock speed because eventually I would like to interface with a RFID reader Ic where the Rx data transmission rate is 15625 baud async. So I picked some 12MHz and 16MHz resonators to play with.
The LCD is a 14 pin, 16x4 character LCD from OPTREX. I assume it's compatable with the common Hitachi LCD controller. The only wierd thing about the LCD was that when I used the "move cursor to beginning of x line" commands, the cursor was a couple of spaces off, so I played with it until it looked right.
Here is my code, it's for a 16F628A, using PBP in MPLAB and MPASM
Code:' PicBasic program to demonstrate operation of an LCD in 4-bit mode ' ' 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 (ground) ' DB0-3 No connect ' ' PIC Configuration ' ================= ' @ __CONFIG _INTRC_OSC_NOCLKOUT & _MCLRE_OFF & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON @ __CONFIG _XT_OSC & _MCLRE_OFF & _LVP_OFF & _WDT_OFF & _PWRTE_ON & _BODEN_ON ' ' Hardware configuration ' ====================== DEFINE OSC 12 CMCON=7 ' disable internal comparator TRISA=0 ' Set all PORTA capable i/o to output TRISB=0 ' Set all PORTB i/o to output ' ' Hardware initialisation ' ======================= DEFINE LCD_LINES 4 Pause 1000 '1 second for LCD initialisation LCDOUT $FE, 1 ' clear LCD ' Start: LCDOUT $FE,2, " WELCOME " LCDOUT $FE,$C0," TO THE " LCDOUT $FE,$90," ELECTRICAL " LCDOUT $FE,$D0," DEPARTMENT " Pause 3000 LCDOUT $FE,2, " " LCDOUT $FE,$C0," Please have " LCDOUT $FE,$90," a seat " LCDOUT $FE,$D0," " Pause 3000 LCDOUT $FE,2, " someone will " LCDOUT $FE,$C0," be with " LCDOUT $FE,$90," you " LCDOUT $FE,$D0," shortly " Pause 3000 Goto Start
Thanks for looking.





Bookmarks