CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

PIC16f877 & LCD problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Vodka



Joined: 13 Sep 2007
Posts: 14

View user's profile Send private message

PIC16f877 & LCD problem
PostPosted: Sun Sep 30, 2007 6:56 am     Reply with quote

Hi all, i`m trying to display something on my lcd but i can`t succeed.
I use a pic16f877 and a lcd(AC202A).
The pinout is:

B0 - unused
B1 - unused
B2 - enable
B3 - rs
B4 - data
B5 - data
B6 - data
B7 - data

rw - GND

so i use a 4 wire data for signalling.I modified the lcd.c file from root as follows(http://www.edaboard.com/ftopic64934.html):
________________________________________________
// Un-comment the following define to use port B
#define use_portb_lcd TRUE
________________________________________________
________________________________________________
struct lcd_pin_map {
BOOLEAN unused1; // For RB0
BOOLEAN unused2; // For RB1
BOOLEAN enable; // For RB2
BOOLEAN rs; // For RB3
int data : 4; // For RB4-RB7
} lcd;
________________________________________________
________________________________________________
comment any line contain 'rw.lcd'
________________________________________________


The main code is:

#include <16F877.h>
#fuses XT // Oscillator mode
#fuses NOLVP, NOWDT // No Low Voltage Program, No Watchdog timer
#fuses NOPROTECT // Code no protection
#use delay(clock=20000000)
#include <lcd.c>

void main()
{

setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);

lcd_init();
lcd_gotoxy(1,1);
lcd_putc("Hello");

}

The CCS compiler is version 3.249

I can`t see anything on my lcd!!!
Please help me,
Regards Vodka
Ttelmah
Guest







PostPosted: Sun Sep 30, 2007 7:22 am     Reply with quote

You have 'XT' selected as the oscillator mode, but 20Mhz shown as the frequency in the delay statement. These two things are incompatible...
Are you sure you have the _right_ data lines selected. Note that in 4bit mode, it is the _high_ four data lines that are used. Double check your wiring.
Check/correct these.
What have you got on the Vlcd line for the display?.

Best Wishes
Vodka



Joined: 13 Sep 2007
Posts: 14

View user's profile Send private message

PostPosted: Sun Sep 30, 2007 8:19 am     Reply with quote

The wiring is all correct and about "What have you got on the Vlcd line for the display?. " i don`t understant what that means.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 30, 2007 6:55 pm     Reply with quote

Here's the data sheet for your LCD. This is a 20x2 LCD.
http://www.ampire.com.tw/Spec-AC/AC-202A.pdf

You're trying to use the LCD with the connections similar
to the schematic shown on this page, except that you
are using PortB instead of PortD and PortE. You are not
using the R/W pin. It's connected to Ground, as shown
in this schematic. Also, you must have a contrast trimpot
connected as shown in this schematic. You can use a 10K
trimpot. Set the initial contrast voltage to 0.5 volts.
http://www.rentron.com/PICX1.htm

I suggest that you don't try to modify the CCS driver.
It's easier to use the Flex driver. See this link:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661

Here are the #define statements that you must have at
the start of the Flex driver:
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_B2
#define LCD_RS    PIN_B3
#define LCD_RW    PIN_B1    // Not actually connected

// *** Comment out the following line ***
// #define USE_LCD_RW   1     
ELCouz



Joined: 18 Jul 2007
Posts: 427
Location: Montreal,Quebec

View user's profile Send private message

PostPosted: Sun Sep 30, 2007 8:26 pm     Reply with quote

also if the lcd is giving you trouble to display something try:
Code:

delay_ms(100);
lcd_init();
lcd_gotoxy(1,1);
lcd_putc("Hello");



this give time to the lcd unit to boot before initialising & sending a command to the display.

Source: --> HERE
Vodka



Joined: 13 Sep 2007
Posts: 14

View user's profile Send private message

PostPosted: Mon Oct 01, 2007 4:30 am     Reply with quote

Unfortunately i have tried the Flex driver and the delay_ms(100); before lcd_init() but i have no luck. If i use the flex driver i can`t see anything on my lcd and if i use the lcd.c file from root and modified as i shown i can see just the first black line appear.
Any new suggestions please ????
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 01, 2007 11:08 am     Reply with quote

Quote:
I can see just the first black line appear.

Here are some posts the problem of "black squares" on the first line
of your LCD.
http://www.ccsinfo.com/forum/viewtopic.php?t=29819
http://www.ccsinfo.com/forum/viewtopic.php?t=30993
http://www.ccsinfo.com/forum/viewtopic.php?t=28405
http://www.ccsinfo.com/forum/viewtopic.php?t=22713
http://www.ccsinfo.com/forum/viewtopic.php?t=23748

Fixing problems when using the Flex driver:
http://www.ccsinfo.com/forum/viewtopic.php?t=27246


Read all those threads and you'll probably find the answer.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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