A discussion group for the PICMicro microcontroller. Also called the Microchip PIC, this list is dedicated to the use and abuse of this fine, simple, microcontroller. Close to topic posts are welcome, ie. general electronics.
LCD 16X2 Problem - Sumit Bhatnagar - Oct 23 19:10:58 2008
I have been trying to get the LCD working with the PIC16F684. The only
thing I could get going is the LCD with one row live and the other
blank. Even the LCD code from myke predko.
I am not sure if there is something wrong with the connections or I am
missing a few resistors and capacitors. But If someone can post a
photo or help me with some directions. The code listing is provided below.
-Sumit
#include
/* cLCD.c - Write a String to a 4 Bit Hitachi 44780 LCD I/F
This Program Initializes Hitachi 44780 Based LCD in 4 Bit Mode
and then writes a simple string to it. The simulator was used
to time delay values.
LCD Write Information can be found at http://www.myke.com
RC3:RC0 - LCD I/O D7:D4 (Pins 14:11)
RC4 - LCD 6 Clocking Pin
RC5 - LCD 4 Pin
myke predko
04.11.08
*/
__CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT \
& UNPROTECT & BORDIS & IESODIS & FCMDIS);
int i, j, k, n; // Use Global Variables for Debug
// 1234567890123456
const char TopMessage[] = " PIC MCU ";
const char BotMessage[] = " Evil Genius ";
#define E RC4 // Define the LCD Control Pins
#define RS RC5
const int Twentyms = 1250; // Declare a Constant for 20 ms Delay
const int Fivems = 300;
const int TwoHundredus = 10;
LCDWrite(int LCDData, int RSValue)
{
PORTC = (LCDData >> 4) & 0x0F; // Get High 4 Bits for Output
RS = RSValue;
E = 1; E = 0; // Toggle the High 4 Bits Out
PORTC = LCDData & 0x0F; // Get Low 4 Bits for Output
RS = RSValue;
E = 1; E = 0; // Toggle the Low 4 Bits Out
if ((0 == (LCDData & 0xFC)) && (0 == RSValue))
n = Fivems; // Set Delay Interval
else
n = TwoHundredus;
for (k = 0; k < n; k++); // Delay for Character
} // End LCDWrite
main()
{
PORTC = 0; // Start with Everything Low
CMCON0 = 7; // Turn off Comparators
ANSEL = 0; // Turn off ADC
TRISC = 0; // All of PORTC are Outputs
// Initialize LCD according to the Web Page
j = Twentyms;
for (i = 0; i < j; i++); // Wait for LCD to Power Up
PORTC = 3; // Start Initialization Process
E = 1; E = 0; // Send Reset Command
j = Fivems;
for (i = 0; i < j; i++);
E = 1; E = 0; // Repeat Reset Command
j = TwoHundredus;
for (i = 0; i < j; i++);
E = 1; E = 0; // Repeat Reset Command Third Time
j = TwoHundredus;
for (i = 0; i < j; i++);
PORTC = 2; // Initialize LCD 4 Bit Mode
E = 1; E = 0;
j = TwoHundredus;
for (i = 0; i < j; i++);
LCDWrite(0b00101000, 0); // LCD is 4 Bit I/F, 2 Line
LCDWrite(0b00000001, 0); // Clear LCD
LCDWrite(0b00000110, 0); // Move Cursor After Each Character
LCDWrite(0b00001110, 0); // Turn On LCD and Enable Cursor
for (i = 0; TopMessage[i] != 0; i++)
LCDWrite(TopMessage[i], 1);
LCDWrite(0b11000000, 0); // Move Cursor to the Second Line
for (i = 0; BotMessage[i] != 0; i++)
LCDWrite(BotMessage[i], 1);
while(1 == 1); // Finished
} // End cLCD
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: LCD 16X2 Problem - harinder singh dalal - Nov 16 6:30:11 2008
post photo of ur ckt.
On Mon, Oct 6, 2008 at 7:22 AM, Sumit Bhatnagar
wrote:
> I have been trying to get the LCD working with the PIC16F684. The only
> thing I could get going is the LCD with one row live and the other
> blank. Even the LCD code from myke predko.
>
> I am not sure if there is something wrong with the connections or I am
> missing a few resistors and capacitors. But If someone can post a
> photo or help me with some directions. The code listing is provided below.
> -Sumit
>
> #include
> /* cLCD.c - Write a String to a 4 Bit Hitachi 44780 LCD I/F
>
> This Program Initializes Hitachi 44780 Based LCD in 4 Bit Mode
> and then writes a simple string to it. The simulator was used
> to time delay values.
>
> LCD Write Information can be found at http://www.myke.com
>
> RC3:RC0 - LCD I/O D7:D4 (Pins 14:11)
> RC4 - LCD 6 Clocking Pin
> RC5 - LCD 4 Pin
>
> myke predko
> 04.11.08
> */
>
> __CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT \
> & UNPROTECT & BORDIS & IESODIS & FCMDIS);
>
> int i, j, k, n; // Use Global Variables for Debug
>
> // 1234567890123456
> const char TopMessage[] = " PIC MCU ";
> const char BotMessage[] = " Evil Genius ";
>
> #define E RC4 // Define the LCD Control Pins
> #define RS RC5
>
> const int Twentyms = 1250; // Declare a Constant for 20 ms Delay
> const int Fivems = 300;
> const int TwoHundredus = 10;
>
> LCDWrite(int LCDData, int RSValue)
> {
>
> PORTC = (LCDData >> 4) & 0x0F; // Get High 4 Bits for Output
> RS = RSValue;
> E = 1; E = 0; // Toggle the High 4 Bits Out
>
> PORTC = LCDData & 0x0F; // Get Low 4 Bits for Output
> RS = RSValue;
> E = 1; E = 0; // Toggle the Low 4 Bits Out
>
> if ((0 == (LCDData & 0xFC)) && (0 == RSValue))
> n = Fivems; // Set Delay Interval
> else
> n = TwoHundredus;
>
> for (k = 0; k < n; k++); // Delay for Character
>
> } // End LCDWrite
>
> main()
> {
>
> PORTC = 0; // Start with Everything Low
> CMCON0 = 7; // Turn off Comparators
> ANSEL = 0; // Turn off ADC
> TRISC = 0; // All of PORTC are Outputs
>
> // Initialize LCD according to the Web Page
> j = Twentyms;
> for (i = 0; i < j; i++); // Wait for LCD to Power Up
>
> PORTC = 3; // Start Initialization Process
> E = 1; E = 0; // Send Reset Command
> j = Fivems;
> for (i = 0; i < j; i++);
>
> E = 1; E = 0; // Repeat Reset Command
> j = TwoHundredus;
> for (i = 0; i < j; i++);
>
> E = 1; E = 0; // Repeat Reset Command Third Time
> j = TwoHundredus;
> for (i = 0; i < j; i++);
>
> PORTC = 2; // Initialize LCD 4 Bit Mode
> E = 1; E = 0;
> j = TwoHundredus;
> for (i = 0; i < j; i++);
>
> LCDWrite(0b00101000, 0); // LCD is 4 Bit I/F, 2 Line
>
> LCDWrite(0b00000001, 0); // Clear LCD
>
> LCDWrite(0b00000110, 0); // Move Cursor After Each Character
>
> LCDWrite(0b00001110, 0); // Turn On LCD and Enable Cursor
>
> for (i = 0; TopMessage[i] != 0; i++)
> LCDWrite(TopMessage[i], 1);
>
> LCDWrite(0b11000000, 0); // Move Cursor to the Second Line
>
> for (i = 0; BotMessage[i] != 0; i++)
> LCDWrite(BotMessage[i], 1);
>
> while(1 == 1); // Finished
>
> } // End cLCD
>
>
>
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: LCD 16X2 Problem - William Gebers - Nov 16 17:12:46 2008
Hi Sumit.
I have the same problem trying to initialise an LCD and haven't found
the solution as I haven't been able to work on it for about 2 weeks.
I did find these two pdf's that I think are very useful and may help you.
www.epemag.wimborne.co.uk/lcd1.pdf
www.epemag.wimborne.co.uk/lcd2.pdf
Once you get it working, please let me know what your solution was.
Regards,
William
2008/10/6 Sumit Bhatnagar
:
> I have been trying to get the LCD working with the PIC16F684. The only
> thing I could get going is the LCD with one row live and the other
> blank. Even the LCD code from myke predko.
>
> I am not sure if there is something wrong with the connections or I am
> missing a few resistors and capacitors. But If someone can post a
> photo or help me with some directions. The code listing is provided below.
> -Sumit
>
> #include
> /* cLCD.c - Write a String to a 4 Bit Hitachi 44780 LCD I/F
>
> This Program Initializes Hitachi 44780 Based LCD in 4 Bit Mode
> and then writes a simple string to it. The simulator was used
> to time delay values.
>
> LCD Write Information can be found at http://www.myke.com
>
> RC3:RC0 - LCD I/O D7:D4 (Pins 14:11)
> RC4 - LCD 6 Clocking Pin
> RC5 - LCD 4 Pin
>
> myke predko
> 04.11.08
> */
>
> __CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT \
> & UNPROTECT & BORDIS & IESODIS & FCMDIS);
>
> int i, j, k, n; // Use Global Variables for Debug
>
> // 1234567890123456
> const char TopMessage[] = " PIC MCU ";
> const char BotMessage[] = " Evil Genius ";
>
> #define E RC4 // Define the LCD Control Pins
> #define RS RC5
>
> const int Twentyms = 1250; // Declare a Constant for 20 ms Delay
> const int Fivems = 300;
> const int TwoHundredus = 10;
>
> LCDWrite(int LCDData, int RSValue)
> {
>
> PORTC = (LCDData >> 4) & 0x0F; // Get High 4 Bits for Output
> RS = RSValue;
> E = 1; E = 0; // Toggle the High 4 Bits Out
>
> PORTC = LCDData & 0x0F; // Get Low 4 Bits for Output
> RS = RSValue;
> E = 1; E = 0; // Toggle the Low 4 Bits Out
>
> if ((0 == (LCDData & 0xFC)) && (0 == RSValue))
> n = Fivems; // Set Delay Interval
> else
> n = TwoHundredus;
>
> for (k = 0; k < n; k++); // Delay for Character
>
> } // End LCDWrite
>
> main()
> {
>
> PORTC = 0; // Start with Everything Low
> CMCON0 = 7; // Turn off Comparators
> ANSEL = 0; // Turn off ADC
> TRISC = 0; // All of PORTC are Outputs
>
> // Initialize LCD according to the Web Page
> j = Twentyms;
> for (i = 0; i < j; i++); // Wait for LCD to Power Up
>
> PORTC = 3; // Start Initialization Process
> E = 1; E = 0; // Send Reset Command
> j = Fivems;
> for (i = 0; i < j; i++);
>
> E = 1; E = 0; // Repeat Reset Command
> j = TwoHundredus;
> for (i = 0; i < j; i++);
>
> E = 1; E = 0; // Repeat Reset Command Third Time
> j = TwoHundredus;
> for (i = 0; i < j; i++);
>
> PORTC = 2; // Initialize LCD 4 Bit Mode
> E = 1; E = 0;
> j = TwoHundredus;
> for (i = 0; i < j; i++);
>
> LCDWrite(0b00101000, 0); // LCD is 4 Bit I/F, 2 Line
>
> LCDWrite(0b00000001, 0); // Clear LCD
>
> LCDWrite(0b00000110, 0); // Move Cursor After Each Character
>
> LCDWrite(0b00001110, 0); // Turn On LCD and Enable Cursor
>
> for (i = 0; TopMessage[i] != 0; i++)
> LCDWrite(TopMessage[i], 1);
>
> LCDWrite(0b11000000, 0); // Move Cursor to the Second Line
>
> for (i = 0; BotMessage[i] != 0; i++)
> LCDWrite(BotMessage[i], 1);
>
> while(1 == 1); // Finished
>
> } // End cLCD
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: LCD 16X2 Problem - cdb - Nov 16 21:55:56 2008
Try the attached - has always worked for me.
Colin
--
cdb, c...@btech-online.co.uk on 17/11/2008
Web presence: www.btech-online.co.uk
Hosted by: www.1and1.co.uk/?k_id=7988359
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: LCD 16X2 Problem - jfcayron - Dec 1 19:42:34 2008
Hi harinder singh dalal,
Could you please post in english? Not everybody understands your language.
Thanks,
JF
--- In p...@yahoogroups.com, "harinder singh dalal"
wrote:
>
> post photo of ur ckt.
>
> On Mon, Oct 6, 2008 at 7:22 AM, Sumit Bhatnagar wrote:
>
> > I have been trying to get the LCD working with the PIC16F684.
The only
> > thing I could get going is the LCD with one row live and the other
> > blank. Even the LCD code from myke predko.
> >
> > I am not sure if there is something wrong with the connections or I am
> > missing a few resistors and capacitors. But If someone can post a
> > photo or help me with some directions. The code listing is
provided below.
> > -Sumit
> >
> > #include
> > /* cLCD.c - Write a String to a 4 Bit Hitachi 44780 LCD I/F
> >
> > This Program Initializes Hitachi 44780 Based LCD in 4 Bit Mode
> > and then writes a simple string to it. The simulator was used
> > to time delay values.
> >
> > LCD Write Information can be found at http://www.myke.com
> >
> > RC3:RC0 - LCD I/O D7:D4 (Pins 14:11)
> > RC4 - LCD 6 Clocking Pin
> > RC5 - LCD 4 Pin
> >
> > myke predko
> > 04.11.08
> > */
> >
> > __CONFIG(INTIO & WDTDIS & PWRTEN & MCLRDIS & UNPROTECT \
> > & UNPROTECT & BORDIS & IESODIS & FCMDIS);
> >
> > int i, j, k, n; // Use Global Variables for Debug
> >
> > // 1234567890123456
> > const char TopMessage[] = " PIC MCU ";
> > const char BotMessage[] = " Evil Genius ";
> >
> > #define E RC4 // Define the LCD Control Pins
> > #define RS RC5
> >
> > const int Twentyms = 1250; // Declare a Constant for 20 ms Delay
> > const int Fivems = 300;
> > const int TwoHundredus = 10;
> >
> > LCDWrite(int LCDData, int RSValue)
> > {
> >
> > PORTC = (LCDData >> 4) & 0x0F; // Get High 4 Bits for Output
> > RS = RSValue;
> > E = 1; E = 0; // Toggle the High 4 Bits Out
> >
> > PORTC = LCDData & 0x0F; // Get Low 4 Bits for Output
> > RS = RSValue;
> > E = 1; E = 0; // Toggle the Low 4 Bits Out
> >
> > if ((0 == (LCDData & 0xFC)) && (0 == RSValue))
> > n = Fivems; // Set Delay Interval
> > else
> > n = TwoHundredus;
> >
> > for (k = 0; k < n; k++); // Delay for Character
> >
> > } // End LCDWrite
> >
> > main()
> > {
> >
> > PORTC = 0; // Start with Everything Low
> > CMCON0 = 7; // Turn off Comparators
> > ANSEL = 0; // Turn off ADC
> > TRISC = 0; // All of PORTC are Outputs
> >
> > // Initialize LCD according to the Web Page
> > j = Twentyms;
> > for (i = 0; i < j; i++); // Wait for LCD to Power Up
> >
> > PORTC = 3; // Start Initialization Process
> > E = 1; E = 0; // Send Reset Command
> > j = Fivems;
> > for (i = 0; i < j; i++);
> >
> > E = 1; E = 0; // Repeat Reset Command
> > j = TwoHundredus;
> > for (i = 0; i < j; i++);
> >
> > E = 1; E = 0; // Repeat Reset Command Third Time
> > j = TwoHundredus;
> > for (i = 0; i < j; i++);
> >
> > PORTC = 2; // Initialize LCD 4 Bit Mode
> > E = 1; E = 0;
> > j = TwoHundredus;
> > for (i = 0; i < j; i++);
> >
> > LCDWrite(0b00101000, 0); // LCD is 4 Bit I/F, 2 Line
> >
> > LCDWrite(0b00000001, 0); // Clear LCD
> >
> > LCDWrite(0b00000110, 0); // Move Cursor After Each Character
> >
> > LCDWrite(0b00001110, 0); // Turn On LCD and Enable Cursor
> >
> > for (i = 0; TopMessage[i] != 0; i++)
> > LCDWrite(TopMessage[i], 1);
> >
> > LCDWrite(0b11000000, 0); // Move Cursor to the Second Line
> >
> > for (i = 0; BotMessage[i] != 0; i++)
> > LCDWrite(BotMessage[i], 1);
> >
> > while(1 == 1); // Finished
> >
> > } // End cLCD
> >
> >
>
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )Re: LCD 16X2 Problem - fabconv - Dec 1 19:42:41 2008
hello everyone
i have the same problem, but i program in picbasicpro
can somebody help me
thanks
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions

(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )
Re: LCD 16X2 Problem - mphillipps2 - Feb 6 8:13:34 2009
The memory for a 16 x 2 LCD is usually arranged 20 x 2.
So if you can't get the function working to move the cursor down to
the next line, you can try writing 4 dummy characters at the end of
the first line, and this should achieve the same result.
------------------------------------
to unsubscribe, go to http://www.yahoogroups.com and follow the instructions
______________________________
Stellaris® MCU Family: New Parts, New Package, New Price.
(You need to be a member of piclist -- send a blank email to piclist-subscribe@yahoogroups.com )