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

PIC16F877A and LCD 16x2 problem
Goto page Previous  1, 2
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Sun Jan 23, 2011 10:02 pm     Reply with quote

Quote:
I'm testing my LCD 16x2 (ABC016002A07-GHY)

This is a direct link to the data sheet:
http://www.es.co.th/Schemetic/PDF/ABC016002A07-GHY.PDF
On page 10, it gives the Backlight specifications.

To fill in the form on the LED resistor calculator website, use these values:
Number of LEDs: 1
LED voltage: 4.2
LED current: 110
Total Voltage: 5
Most of those numbers come directly from page 10 of the LCD data sheet.
Given those values, the form suggests a 7.5 ohm resistor. However, to
be safe, maybe it's better to begin with a 15 or 22 ohm resistor.
champ720



Joined: 22 Dec 2010
Posts: 12

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 12:50 am     Reply with quote

Hello, PCM

I connect series LED resistor 15 ohm, 0.5W and do anything you suggest but it doesn't work. what is next your idea ?


Thank you very much.
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Tue Jan 25, 2011 4:20 pm     Reply with quote

That circuit only affects the backlight. You don't need the backlight
to be working. The LCD will run without it.

Did you do you all the things I listed in my post below?
http://www.ccsinfo.com/forum/viewtopic.php?t=44512&start=13
You don't need to worry about the backlight. Just do all the things
I listed in the post. Get the LCD working first.

If the LCD doesn't work, then maybe you destroyed it accidentally by
reversing the +5v and Ground connections.
champ720



Joined: 22 Dec 2010
Posts: 12

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 11:25 pm     Reply with quote

PCM programmer wrote:
That circuit only affects the backlight. You don't need the backlight
to be working. The LCD will run without it.

Did you do you all the things I listed in my post below?
http://www.ccsinfo.com/forum/viewtopic.php?t=44512&start=13
You don't need to worry about the backlight. Just do all the things
I listed in the post. Get the LCD working first.

If the LCD doesn't work, then maybe you destroyed it accidentally by
reversing the +5v and Ground connections.


Thank you PCM,

LCD works now. I think my problem is power supply and ground is not good. When I connect PIC with GPS module, LCD works fine but GPS doesn't work.

If I use circular buffer without interrupt, it works unsmoothly. Also, I add interrupt service code (EX_SISR.c in PCWHD compiler), but nothing received through RS232. How can I solved this interrupt code problem?


This code without Interrupt


Code:
//---------------Without Interrupt--------------------//

#include <16F877A.h>          // Standard Header file for the PIC16F877A
#include <stdlib.h>
#include <math.h>


#fuses HS,NOWDT,NOPROTECT,NOLVP       // Configuration word
#use delay(clock=20000000)       // oscillator
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Standard output


#include "flex_lcd.c"


#define BUFFER_SIZE 70
int gps_data[BUFFER_SIZE]={};
int i = 0;

void main(void)
{
   lcd_init();
   lcd_putc("\f");      //Clear display
   lcd_gotoxy(1,1);
   lcd_putc("GPS Test");


   while(TRUE)
   {

      gps_data[i]=getch();
       putc(gps_data[i]);
      i++;
      if (i>BUFFER_SIZE-1)
      {
         i=0;
      }
      
    }

}


This code with Interrupt

Code:
#include <16F877A.h>          // Standard Header file for the PIC16F877A
#include <stdlib.h>
#include <math.h>


#fuses HS,NOWDT,NOPROTECT,NOLVP       // Configuration word
#use delay(clock=20000000)       // oscillator
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)  // Standard output


#include "flex_lcd.c"


#define BUFFER_SIZE 70
BYTE buffer[BUFFER_SIZE];
BYTE next_in = 0;
BYTE next_out = 0;


#INT_RDA

void gps_isr()
{
   int t;
   buffer[next_in] = getc();
   t = next_in;
   next_in = (next_in+1)%BUFFER_SIZE;
   
   if(next_in == next_out)
      {
         next_in = t;      //Buffer full
      }

}


#define bkbhit (next_in!=next_out)

BYTE bgetc()
{
   BYTE c;

   while(!bkbhit) ;
      c=buffer[next_out];
      next_out=(next_out+1)%BUFFER_SIZE;
   return(c);
}



void main(void)
{
   lcd_init();
   lcd_putc("\f");      //Clear display
   lcd_gotoxy(1,1);
   lcd_putc("GPS Test");


   delay_ms(200);
   
    enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);


   do
   { 
      delay_ms(500);
      while(bkbhit)   
      putc(bgetc());
         
   } while (TRUE);


}
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 11:44 pm     Reply with quote

Quote:
do
{
delay_ms(500);
while(bkbhit)

putc(bgetc());

} while (TRUE);

Delete the two lines in bold.
champ720



Joined: 22 Dec 2010
Posts: 12

View user's profile Send private message

PostPosted: Wed Jan 26, 2011 11:55 pm     Reply with quote

PCM programmer wrote:
Quote:
do
{
delay_ms(500);
while(bkbhit)

putc(bgetc());

} while (TRUE);

Delete the two lines in bold.


I delete these two lines, but it doesn't work.
PCM programmer



Joined: 06 Sep 2003
Posts: 21477

View user's profile Send private message

PostPosted: Thu Jan 27, 2011 1:51 pm     Reply with quote

I don't understand your program.

Here, you use the LCD to display output:
Quote:
void main(void)
{
lcd_init();
lcd_putc("\f"); //Clear display
lcd_gotoxy(1,1);
lcd_putc("GPS Test");



But then down here, you get characters from the GPS on the serial port.
But then you just transmit them back on the serial port, using putc().
What's the purpose of that ? Where is the transmit line of the PIC's
serial port going ? To the GPS ? Or to the PC ?
Quote:

do
{
delay_ms(500);
while(bkbhit)
putc(bgetc());

} while (TRUE);


}

Are you using a split rs232 cable, and receiving characters from the GPS
and sending them to the PC ?

Do you really want to send GPS data to the LCD, instead, and you just
made a mistake by using putc(bgetc()) above ?

Is this a Proteus program or is this real hardware ?
champ720



Joined: 22 Dec 2010
Posts: 12

View user's profile Send private message

PostPosted: Thu Jan 27, 2011 6:14 pm     Reply with quote

Hello PCM,
I'm doing GPS data logger which display lat/long at LCD and connected laptop's usb cable for navigation. I add LCD for displaying lat/long when GPS isn't connected to laptop.

Now, I'm testing first step, receiving GPS data (by interrupt service) and display on hyper terminal. If it works, I will program code to display lat/long on LCD later. I test all on proto board.

Moreover, I attach my circuit for considering it.


Thank you,



Uploaded with ImageShack.us
ezflyr



Joined: 25 Oct 2010
Posts: 1016
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri Jan 28, 2011 8:58 am     Reply with quote

Hi,

What GPS module are you using. Post a link to the datasheet!

Your use of 500 ohm "pull-ups" on the Tx and Rx lines of the PIC is "interesting"...... My guess is that the Schmitt Trigger input on the Rx input is not compatible with your GPS receiver output. You'll probably need a proper level shifter.

John
andrewg



Joined: 17 Aug 2005
Posts: 316
Location: Perth, Western Australia

View user's profile Send private message Visit poster's website

PostPosted: Fri Jan 28, 2011 10:51 pm     Reply with quote

I hope they aren't 33pF I'm seeing either side of the 7805! I'd expect something more like 33uF, but at least 10uF is what I'd have, maybe up to 200uF (no real upper limit) on the "out" side.
_________________
Andrew
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page Previous  1, 2
Page 2 of 2

 
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