![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
Hi all,I am new to this forum.I interfaced pic18f4550 microcontroler to lcd ,I wrote the c program and compiled it in mikro c compiler.The code I compiled was example provided by mikroc. it was actually written for pic18f8520 I changed to 18f4550 in the project window.the problem is, i am not getting anything on the screen.can anyone help to solve this problem? The oscillator used is crystal 8Mhz trim pot 5k to contrast change. lcd(16*2 display) similar to hd44780,it has 8 data bits d0 to d7,vcc,vss,backlight led all similar to hd44780. The c program is below /* * Project name: Lcd_Test (Simple demonstration of the LCD Library functions) * Copyright: (c) MikroElektronika, 2005. * Description: This is a simple demonstration of LCD library functions. LCD is first initialized (PORTB, 4-bit data interface, default pin settings), then some text is written at the first row. * Test configuration: MCU: P18F8520 Dev.Board: BIGPIC4 Oscillator: HS, 10.0 MHz Ext. Modules: LCD SW: mikroC v8.0 * NOTES: None. */ char *text = "mikroC_123"; void main() { unsigned short btnRes; CMCON |= 0x07; // turn off comparators ADCON1 |= 0x0F; // turn off analog input // disable external memory bus Lcd_Custom_Config(&PORTb, 7,6,5,4,&PORTb, 2,4,3); // Initialize LCD connected to PORTH Lcd_Custom_Cmd(LCD_CLEAR); // Clear display Lcd_Custom_Cmd(LCD_CURSOR_OFF); // Turn cursor off Lcd_Custom_Out(1,1, text); // Print text to LCD, 2nd row, 1st column Lcd_Custom_Chr_CP('@'); Lcd_Custom_Chr(1,14, '#'); Lcd_Custom_Cmd(LCD_SECOND_ROW); Lcd_Custom_Out_CP(text); while (1) ; // endless loop }//~! | |
| |
| | #2 |
|
Compile your code and load the hex into the Oshonsoft simulator. If that works then you most likely have a hardware problem. The example you have looks like it uses a 4 bit interface. At a guess (I don't have mikroC) it is using RB7/6/5/4 for the data and RB2/4/3 for the 3 control pins. A diagram of how you have wired it would help. | |
| |
| | #3 |
|
the code is ok the possible problems are 1. configuration. are you sure you set config bits properly 2. hw setup, did you connect the lcd same way you configured the lcd function (B7-B4 for DATA, B2.3.4 for control)
__________________ Bits From Bytes - the best RepRap kit out there now featuring RepRap V3 with full electronics redesign based on PIC32MX440F256H (English) MySQL Blog (Serbian) Elco Blog (Serbian) Use forum to ask questions, do not use PP | |
| |
| | #4 |
|
thanks for your support. I checked the connections but still i am not getting any display except few black blocks on right side of the lcd display when I varied potentiometer to give max. resistance. I downloaded Oshonsoft simulator and tried it took more than ahour and displayed nothing on lcd simulator.Am I doing any mistake here ? one boubt I am having is that above example is for pic18f8520 which is a 80 pin microcontroller,I just set to pic18f4550,8Mhz in project window.so will the program written for 80 pin when converted to 40 pin pic will we get output successfully ? can you tell whats wrong I am doing here?. | |
| |
| | #5 | |
|
I don't use MikroC, but your control and data had same pin (4), so when data change the control also change, result Lcd don't know what to do. just try change control pin(4) to 1 Quote:
| ||
| |
| | #6 |
|
Hi, look at the given code - use Mikroelektronika`s LCD library for 2x16 text display (included in meny Tools). I have EasyPIC3 at 8MHz with the PIC18F4550 and this library works fine. Also, turn OFF the watchdog! Use Lcd_Init for default pin settings (see the first figure below). char *text = "mikroElektronika"; void main() { TRISB = 0; // PORTB is output Lcd_Init(&PORTB); // Initialize LCD connected to PORTB Lcd_Cmd(Lcd_CLEAR); // Clear display Lcd_Cmd(Lcd_CURSOR_OFF); // Turn cursor off Lcd_Out(1, 1, text); // Print text to LCD, 2nd row, 1st column }//~! LCD HW connection by default initialization (using Lcd_Init) Last edited by Peca; 28th March 2009 at 02:38 PM. | |
| |
|
| Tags |
| interfacing, lcd, pic |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| USB - First try - PIC 18F4550 | atferrari | Micro Controllers | 8 | 28th April 2008 11:48 AM |
| Pic 18f4550 | watzmann | Micro Controllers | 3 | 29th February 2008 06:19 PM |
| 18f4550 RC0 | HerbertMunch | Micro Controllers | 2 | 19th February 2008 11:59 AM |
| plz help on pic 18f4550 | shetti.umesh | Electronic Projects Design/Ideas/Reviews | 1 | 9th February 2007 05:50 AM |
| Pic 18f4550 & VB6 | lentz | Micro Controllers | 0 | 7th March 2006 07:24 PM |