The posted TXT is the HEX compiled version of the program below. Download it, rename is as HEX (this forum doesn't permit HEX extensions on attachments at this time), and stuff it into your PIC. It assumes your PIC is running at 4MHz.
Ensure your connect your LCD EXACTLY as per the schematic. If you haven't already done so, go back and check again. Ensure LCD-D4 connects to PortB0 etc. Ensure LCD-D0 thru LCD-D3 are grounded to Vss (0v).Code:' ' LCD Test Program ' ================ ' ' PIC Defines ' ----------- @ DEVICE pic16F84, XT_OSC ' System Clock Options @ DEVICE pic16F84, WDT_ON ' Watchdog Timer @ DEVICE pic16F84, PWRT_ON ' Power-On Timer @ DEVICE pic16F84, PROTECT_OFF ' Program Code Protection ' ' Hardware Defines ' ================ ' ' LCD Display ' ----------- ' Don't forget to GROUND D0-D3 on LCD. ' Define LCD_DREG PORTB ' Port for LCD Data Define LCD_DBIT 0 ' Use lower 4 bits of Port Define LCD_RSREG PORTA ' Port for RegisterSelect (RS) bit Define LCD_RSBIT 1 ' Port Pin for RS bit Define LCD_EREG PORTA ' Port for Enable (E) bit Define LCD_EBIT 2 ' Port Pin for E bit Define LCB_BITS 4 ' Using 4-bit bus Define LCD_LINES 2 ' Using 2 line Display Define LCD_COMMANDUS 2000 ' Command Delay (uS) Define LCD_DATAUS 50 ' Data Delay (uS) ' ' ' Confidence LED ' -------------- ' This LED will BLINK continuously to prove your program is running ' and will verify your oscillator/xtal is good. ' Connect LED either... ' (a) Anode to Vdd (+5v) via 330R Resistor and Kathode to pin A0 ' or (b) Anode to pin A0 via 330R Resistor and Kathode to Vss (0v). ' BlinkyLED var PortA.0 ' This LED will BLINK ' ' Program Start ' ------------- TRISA=%00000000 ' Set all I/O to OUTPUT TRISB=%00000000 ' Pause 2000 ' Wait 2 seconds for Hardware to settle ' should account for the crappiest and ' slowest junk LCD Loop: LCDOUT $FE,1 ' Clear LCD High BlinkyLED ' Set LED pin High Pause 1000 ' Wait one Second LCDOUT "Hello Dj tempo" ' Write message Low BlinkyLED ' Set LED pin Low Pause 1000 ' Wait one Second Goto Loop ' Loop around and do it forever End
If your connect an LED as directed in the listing and it doesn't blink, check your oscillator circuit. Easiest for novices is to use a 4MHz 3-pin ceramic Resonator with integral Capacitors.
If the LED blinks, but still nothing on the LCD, then connect a 10K Pot between Vdd and Vss with the wiper going the the Contrast Vo pin, instead of having that pin connected directly to Ground. Some LCD's don't like having the Contrast pin connected directly to Vss, it applies TOO MUCH contrast and all you get is solid black squares. Yet if that pin is left unconnected, you don't get anything displaying either.
Good luck with the faultfinding - it's actually the fun part of electronics.
Melanie




Bookmarks