View previous topic :: View next topic |
Author |
Message |
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
Faulty LCD |
Posted: Mon Dec 31, 2012 5:37 am |
|
|
How you know that LCD is damaged? I tried several programs and the only output I have on the LCD is just the top line showing white boxes |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9226 Location: Greensville,Ontario
|
|
Posted: Mon Dec 31, 2012 6:50 am |
|
|
Without seeing your code and the LCD module information
that sounds more likely a 'bad' program.
From your description, I'm thinking you have a 2 or 4 line LCD module that does power up and is in 8 bit mode.
I do know that the flex_lcd driver here works on 5 different modules.
show us your code, PIC type, and compiler info.....
hth
jay |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 7:02 am |
|
|
this is the code:
Code: | #include "trial.h"
#define LCD_ENABLE_PIN PIN_B5
#define LCD_RS_PIN PIN_B7
#define LCD_RW_PIN PIN_B6
#define LCD_DATA4 PIN_D7
#define LCD_DATA5 PIN_D6
#define LCD_DATA6 PIN_D5
#define LCD_DATA7 PIN_D4
#include "lcd.c"
int count;
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(SPI_SS_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab
set_tris_a(0x00);
output_a(0x0000000);
lcd_init();
delay_ms(500);
while(1)
{
count++;
lcd_putc ("/f");
lcd_gotoxy(1,1);
lcd_putc (count);
output_toggle(PIN_A0);
delay_ms(1000);
}
} |
I am using 4 line communication |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Dec 31, 2012 8:03 am |
|
|
You have not answered two of the three questions answered:
PIC type, and compiler version.
Some comments though:
setup_spi(SPI_SS_DISABLED);
Does not turn off the SPI. If on your chip one of the LCD pins is an SPI pin, this would stop it from working.
Correct syntax is:
setup_spi(FALSE);
Are your four data lines really reversed?.
You need a total of ten lines connected to the LCD. The seven listed in the code, plus ground, 5v, and Vee (the LCD contrast voltage). A display will wake up without the last, but depending on the unit may well just show one line of solid rectangles.
Best Wishes |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 8:40 am |
|
|
I am using the PIC18F4550. In fact the SPI Pins are not effected. I used the general purpose pins on port B and port D. The crystal is 12mHz and compiler version is: 4.093 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Dec 31, 2012 8:59 am |
|
|
So, are the four data lines actually reversed?.
Move the delay _in front_ of lcd_init.
A lot of third party displays need extra time to actually wake up.
Have you actually done a basic test and verified your chip is running and at the correct speed (toggle an LED on a pin)?.
Best Wishes |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 9:09 am |
|
|
what do you mean by reversed? Actually the led is not toggle at all! When I removed all the lcd functions and kept only the led toggling (to verify that the PIC is good), the program worked fine. |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 9:17 am |
|
|
I made delay_ms(1000) before the lcd_init() to be 100% sure that it has enough time but still no luck :( |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19515
|
|
Posted: Mon Dec 31, 2012 9:18 am |
|
|
You have the top bit of the port (D7), going to the low bit of the LCD (D4), etc... |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 9:21 am |
|
|
sorry but I am not understanding your point...
I have the following :
D7 => DATA4
D6 => DATA5
D5 => DATA6
D4 => DATA7
there is any problem with this configuration? |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 9:24 am |
|
|
I have made the following :
D7 => DATA7
D6 => DATA6
D5 => DATA5
D4 => DATA4
...still no luck |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Dec 31, 2012 10:26 am |
|
|
Hi,
OK, but you haven't fully answered all the questions that have been asked.
Ttelmah asked if the chip is running at the correct speed. You didn't answer
that question, only that the LED was flashing. You need to use a reasonable
delay time, such as 1 second, and then verify that the LED is toggling at that
rate. If the chip is running slower or faster than expected, you won't get the
LCD to work.
The fact that the code 'hangs' (the LED stops flashing) when the LCD routines
are added suggests that the code is stopping inside the LCD.c module. If I
were trying to debug this problem, I would do three things immediately:
1. Run the 'LED test' to verify the CPU is running at the desired speed.
2. Switch to the 'flex_lcd.c' LCD driver.
3. Disable, at least for now the R/W capability of the display. This is
described in the flex_lcd driver docs.
John |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 11:18 am |
|
|
dear all,
I continue to work on this problem and finally I worked! I mapped the pinouts in this order:
A0 => RS
A1 => RW
A2 => Enable
A3 => DATA4
A4 => DATA5
A5 => DATA6
E0 => DATA7
I do not know if there must be Pinouts Order! In this way all the program is working correctly with the correct cpu speed...20MHz. |
|
|
ezflyr
Joined: 25 Oct 2010 Posts: 1019 Location: Tewksbury, MA
|
|
Posted: Mon Dec 31, 2012 12:10 pm |
|
|
Hi,
Did this line of code work as intended?
John |
|
|
aaronik19
Joined: 25 Apr 2011 Posts: 297
|
|
Posted: Mon Dec 31, 2012 12:12 pm |
|
|
In fact I corrected it! It must be:
to clear the display |
|
|
|