|
|
View previous topic :: View next topic |
Author |
Message |
AsmallGuy Guest
|
LCD: first try |
Posted: Sat Mar 28, 2009 10:45 am |
|
|
Hi, I'm trying to display on a LCD (16x2) something using a PIC16F886 (port_b), but I'm not having much success.
This is the basic code:
Code: |
#include "main.h"
#include <LCD.C>
void main()
{
setup_adc_ports(NO_ANALOGS|VSS_VDD);
setup_adc(ADC_OFF);
setup_spi(SPI_SS_DISABLED);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_oscillator(OSC_8MHZ);
lcd_init();
output_low(PIN_C3);
delay_ms(500);
output_high(PIN_C3);
delay_ms(500);
output_low(PIN_C3);
lcd_putc("\fgagagag");
while(1);
} |
It looks like it hangs on the lcd_init(); instruction cause the LED never blinks.
Inside the LCD.c I've uncommented the line Code: | #define use_portb_lcd TRUE | .
Now, after looking at the code, assuming HW connections correct (big assumption, 7 pins to connect + gnd, vdd and contrast), right after I power up the display (the LCD alone,) I see the uppermost row fully black and the 2° line blank, is this the normal behaviour?
Tnx all. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Guest
|
|
Posted: Sat Mar 28, 2009 11:36 am |
|
|
That's the flex_lcd, I've already tried it without luck.. or experience.
I've attached a potentiometer to the LCD, when I apply power to Vdd and ground gnd, then I can vary the power to V0 and see the contrast varying; but I can only see the first row; the second row stays blank, no contrast effect on it :(
This is the main.h (compiler version 4.084):
Code: |
#include <16F886.h>
#device *=16
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES PUT //Power Up Timer
#FUSES NOMCLR //Master Clear pin used for I/O
#FUSES NOPROTECT //Code not protected from reading
#FUSES NOCPD //No EE protection
#FUSES NOBROWNOUT //No brownout reset
#FUSES NOIESO //Internal External Switch Over mode disabled
#FUSES FCMEN //Fail-safe clock monitor enabled
#FUSES NOLVP //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG //No Debug mode for ICD
#FUSES NOWRT //Program memory not write protected
#use delay(clock=8000000)
|
I'll try wth a smaller PIC device.
When I tried with the flex_lcd.c the header was (meaning I modified pin connection to some easy to check):
Code: |
#define LCD_DB4 PIN_B4
#define LCD_DB5 PIN_B5
#define LCD_DB6 PIN_B6
#define LCD_DB7 PIN_B7
#define LCD_E PIN_B3
#define LCD_RS PIN_B2
#define LCD_RW PIN_B1
// If you only want a 6-pin interface to your LCD, then
// connect the R/W pin on the LCD to ground, and comment
// out the following line.
#define USE_LCD_RW 1
//========================================
#define lcd_type 2 // 0=5x7, 1=5x10, 2=2 lines
#define lcd_line_two 0x40 // LCD RAM address for the 2nd line
|
What is the behaviour of a LCD when attached to power? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Mar 28, 2009 11:45 am |
|
|
Quote: | What is the behaviour of a LCD when attached to power? | Usually nothing. It shows a blank screen.
There have been many, many threads on here about how to get an LCD
to work. I think the most typical problem is bad connections. The person
doesn't believe they have bad wiring, but eventually they find out that's
what it is. |
|
|
AsmallGuy Guest
|
|
Posted: Sat Mar 28, 2009 11:53 am |
|
|
Right, I was looking into the forum, and before pointing at the code AND assuming (right or wrong) correct connections, i was just curious about the behaviour of a LCD powered up; mine has something of it's own, because with just Vdd, GND and contrast pin connected is displaying the first row fully black, the second blank.
So, second step: triple check connections/wiring - now I assume code is correct, wiring is faulty.
For sake of curiosity I'll let you know what went wrong! |
|
|
AsmallGu Guest
|
|
Posted: Mon Mar 30, 2009 2:19 am |
|
|
Ok, big news here!
First: when you connect to power, gnd and V0 a LCD (16x2 standard) it HAS TO light up the first row (fully black matrix) and leave blank the second row, this by datasheet specification, is indicating the display controller is working fine (so it should not stay full blank).
Second: i've throw away the 16F886 and used a reliable 16F684, used the flex_lcd, make sure to assign the right pins (just changed port names) and ZAC!! i got the LCD working really nice in no time!
.. as usually, the bigger they grow, the harder to make 'em clock.. :( - i'll end up in my project wiring up some '684 via some simple protocol to exchange data and act on the various peripherals.. (it would be too easy to just use a '886..) |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|