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 CCS Technical Support

LCD Trouble

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



Joined: 23 Apr 2005
Posts: 73

View user's profile Send private message Send e-mail AIM Address

LCD Trouble
PostPosted: Fri Apr 29, 2005 3:39 pm     Reply with quote

I am attempting to interface an LCD (HD44780 based) 16x2 to my PIC18F1320. I enabled use of port B in the CCS driver lcd.c since the PIC18F1320 only has ports A and B available. Here is the code I am using to test the LCD:

#include <18F1320.h>
#include <lcd.c>
#fuses NOWDT,NOPROTECT,NOLVP,NOMCLR,INTRC_IO// CCPB0
#use delay(clock=8000000)
#byte OSCCON=0b01111111 //8 MHz

void main()
{

set_tris_a(0x00);
output_a(0x00);
output_b(0x00);
lcd_init();
output_high(PIN_A0);
lcd_putc("\fHello World!");
}

I am using pin A0 to test whether the LCD is actually getting through the init sequence as it should be, but something strange happens. I turn on Vdd and nothing happens for about 30 seconds, then all of a sudden the LED comes on momentarily then flickers out (although it isn't burning out) and the power supply voltage drops from 5V (which I set it at) to about 1.5V and I cannot change it (I am using a dual variable power supply). Nothing shows up on the LCD screen either. I also noticed that part of the LCD gets very hot once the voltage drops and I would think this would mean something is shorting (pins connected incorrectly), though I have no clue why it would take 30 seconds for this to happen. There is a contrast adjust pin that I just tied to ground, thinking this would give maximum contrast and I would see something if the LCD was powering up correctly, but I see nothing. Any help would be appreciated if anyone has ever experienced anythign like this before!
akokyaw



Joined: 11 Feb 2005
Posts: 24

View user's profile Send private message

try the command ADCON1
PostPosted: Fri Jun 24, 2005 10:43 pm     Reply with quote

Hi,
Try the command ADCON1 that is actually the register for ADC. I believe that 18F1320 has ADC function at portA and by default portA is set to analog function. In order to drive lcd, you should set portA to digital function. I hope that will help.

Rgds,
ak
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Jun 24, 2005 11:23 pm     Reply with quote

1. You're not really setting OSCCON register. The #byte statement
is used to define the address of a register, not to set it to a value.
You need to look up the address of OSCCON in the data sheet
and use that number instead of what you're using. Look in this
section: Memory Organization / Special Function Registers

Then if you need to set OSCCON, do it with a line of code in main().
Treat OSCCON just like any other variable.

Depending on your version of the compiler, you shouldn't have to
set OSCCON. I tested your code with vs. 3.188, and CCS inserts
start-up code that sets OSCCON = 0x70, which is proper for 8 MHz.

2. You're letting your program fall off the end of main(), where it hits
a hidden SLEEP instruction which is placed there by the compiler.
That may not actually be causing your problem.

3. Do you have a series resistor connected to your LED, to limit the
current through it ? (Something in the range from 270 to 47O ohms).

4. If the LCD is getting very hot, it's likely wired incorrectly. I would
look for a reversal of +5 and GND. 16x2 LCD's usually have a dual
row header pin arrangement. One side has all the odd numbered
pins, and the other side has the even numbered pins. Pin one is
indicated by a square pad. The others are round. You may need
a new LCD.

5. With regard to the comment about Port A -- CCS puts in start-up
code to configure it as all digital. I checked vs. 3.188, and at
least in that version, the code is correct.
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

View user's profile Send private message Send e-mail

PostPosted: Sat Jun 25, 2005 8:09 am     Reply with quote

This is a really old post. Bryan actually posted it a couple of times and has resolved his problem
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