![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hi:
I am trying to print few words on an 8 bits 2x16 LCD with Hitachi controller, but I am not able to print anything, I just see a thin line blinking few times. I am using PIC18, but the pic choice does not matter since this is my first LCD code, and I think it must be code problem, and I would guess it must be in the init method, because I am not very sure about it. Here is the code: #define LCD_EN 1 // Port A bit 0 ( Enables LCD ) #define LCD_WR 2 // Port A bit 1 ( Logic 0 = Write ) #define LCD_RS 4 // Port A bit 2 ( Register select 1=Data transfer) // PortD is D0-D7 void lcd_clear(void) { setInstructionBit_Lo(LCD_RS); PORTA &= 0xf0; //PORTD = 0x01; lcd_write(0x01); delay(4000); setInstructionBit_Hi(LCD_RS); } void LCD_Toggle_EN(void) { setInstructionBit_Hi(LCD_EN); delay(4000); setInstructionBit_Lo(LCD_EN); delay(4000); } void LCD_init(void) { delay (8000); //30ms Power ON delay setInstructionBit_Lo(LCD_RS); lcd_write(0x0c); // // Display is ON lcd_write(0x0e); // cursor active and no blink //lcd_write(0x0f); // cursor active and blink LCD_Toggle_EN(); lcd_write(1); // clear display LCD_Toggle_EN(); lcd_write(0x38); // 8 bit data mode 2 line ( 5x7 font ) LCD_Toggle_EN(); setInstructionBit_Hi(LCD_RS); } void main (void) { TRISD = 0; TRISA = 0; PORTA = 0x00; PORTD = 0x00; LCD_init(); while (1) { lcd_clear(); lcd_write('T'); lcd_write('e'); lcd_write('s'); lcd_write('t'); lcd_write('!'); } } PS: This LCD has 16 pins, and supposedly has a LED backlight, I am not sure how to turn this LED ON, I tried to connect pin15 to GND, and pin16 to +5V, but it did not work. If you could help, please do. Thanks a lot folks. |
|
|
|
|
|
|
(permalink) |
|
hi joe,
I expect you have got a copy of the HD44780 datasheet. From power ON, wait for at least 40mSec before you start to initialise. Write 0x38, the BUSY cannot be tested yet. Wait 5mSec Write 0x38 again, still no BUSY test. Wait 100uSec Write 0x38 again Write the Init instruction set, after each Instr you can now test the BUSY bit[D7] Whats you PIC clock rate, the controller 'Enb' strobe must be at least 1uSec duration, you may need to pad out the Control line signals with NOP's.
__________________
Eric "Good enough is Perfect" PIC tutorials: Gramo's: www.digital-diy.net/ Bill's: www.blueroomelectronics.com/ |
|
|
|
|
|
|
(permalink) |
|
Hey Joe,
Check this one: http://www.electro-tech-online.com/m...c-screwup.html If you wait long enough, more than the datasheet recommend, it should be ok. For me it is anyway. I always send the commands only once with no problem at all Regarding the backlight, you sure it's LED and not EL foil (require driver), you know very thin foil that fits between LCD and PCB. I have here several LCD's from different suppliers Hitachi, Hyundai, Sharp, Optrex some with LED some with EL BL, 14 pins and 16 pins, all are different. The Hyundai ones are marked A and K for the backlight so no confusion possible. Google brand and type for datasheet or post a good picture of yours here, then, maybe we can help you further... |
|
|
|
|
|
|
(permalink) |
|
Thanks guys for the hints, it is working now.
I was not sending the 0x38 three times and I did not have long enough delay. As for the back light LED, I had it connected backward and it is also working now. I actually was using spec for different LCD. Apparently it is not standard. Thanks again. |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| 89c4051 4-bit controlled LCD sporadic screwup | Pax Writer | Micro Controllers | 7 | 26th April 2007 05:58 AM |
| LCD Template Code For PIC16F84A (Help) | Peter_wadley | Micro Controllers | 23 | 4th April 2007 03:47 AM |
| PIC 16F877A - Problem with A/D conversion | disco_dave | Micro Controllers | 11 | 17th February 2006 02:54 AM |
| RF tranceiver problem | darvaish | General Electronics Chat | 2 | 3rd April 2005 07:44 AM |
| Big thermocouple ADC problem | Oznog | General Electronics Chat | 9 | 4th May 2004 08:42 PM |