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 and Serial LCD

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



Joined: 06 Jul 2009
Posts: 4

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

Pic16F877 and Serial LCD
PostPosted: Mon Jul 06, 2009 8:02 pm     Reply with quote

Hi all

ok just starting out in PIC micros and C programming. I played with them a bit usings PICASM but I couldn't wrap my head around it. I bought the Martin P Bates book Programming 8-bit Pic Microcontrollers in C. Overall the book is good in my opinion. I'm trying to get some code to work simulating a 16F877A and LCD using Lab Center ISIS.

The code is taken directly out of Martin P Bates book.
Code:

#include "16F877a.h"
#use delay (clock=4000000)
#use rs232(baud=9600, xmit=PIN_D0, rcv=PIN_D1)
void main()
{
   char acap='A';

   delay_ms(1000);
   putc(254); putc(1);
   delay_ms(10);

   while(1)
   {
      putc(acap);
      putc(254); putc(192); delay_ms(10);
      printf("ASCII %c   CHAR %d ",acap,acap);
      while(1);
        }

The LCD is the [spam] 16x2 serial LCD. When the code is executed all I get is a series of Xs on the display.

Anybody have an idea to the cause?
Guest








PostPosted: Mon Jul 06, 2009 9:11 pm     Reply with quote

Hi,

Those displays appear to use the Scott Edwards 'backpack' serial modules. The data sheet for the backpack module says that the serial input can be 'RS232 or INVERTED TTL levels'. You are using TTL levels, so you need to add the INVERT option to your #use rs232 definition.

John
Guest








PostPosted: Tue Jul 07, 2009 6:15 am     Reply with quote

Hi,

One other thing I thought of is that the 'invert' option only works with a 'software' serial port (ie. if you ARE NOT using the hardware UART). I don't have a datasheet handy, but I don't think you are. Please check! If you do need to use the hardware serial port, you'd need to add a hardware inverter between the PIC and the serial display.

John
aschenk



Joined: 06 Jul 2009
Posts: 4

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

Re: Pic16F877 and Serial LCD
PostPosted: Tue Jul 07, 2009 11:37 am     Reply with quote

OK I got my code to work. Funny, all I had to do is change the clock from 4000000 to 8000000 and it works.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 07, 2009 12:49 pm     Reply with quote

You're using the Proteus simulator. Probably most of us don't have
Proteus. So there's no way for us to test your problem. Furthermore,
we can't go "look up" the data sheet for the LCD. It's a simulation.
That's why you didn't get many posts offering help.
Guest








PostPosted: Tue Jul 07, 2009 9:03 pm     Reply with quote

PCMProgrammer said: "That's why you didn't get many posts offering help."

Excuse me? Based on the limited information presented, I make a good faith effort to help this user solve his problem. Your comment seems a bit dismissive of my efforts Shocked

John
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 07, 2009 9:26 pm     Reply with quote

I was talking about the original poster, not you. I like your posts.
I halfway regretted making that post. I should have followed my
instinct and not made it.
aschenk



Joined: 06 Jul 2009
Posts: 4

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

Re: Pic16F877 and Serial LCD
PostPosted: Wed Jul 08, 2009 6:54 am     Reply with quote

Hey John
Thanks for your help!

A[



quote="aschenk"]Hi all

ok just starting out in PIC micros and C programming. I played with them a bit usings PICASM but I couldn't wrap my head around it. I bought the Martin P Bates book Programming 8-bit Pic Microcontrollers in C. Overall the book is good in my opinion. I'm trying to get some code to work simulating a 16F877A and LCD using Lab Center ISIS.

The code is taken directly out of Martin P Bates book.
Code:

#include "16F877a.h"
#use delay (clock=4000000)
#use rs232(baud=9600, xmit=PIN_D0, rcv=PIN_D1)
void main()
{
   char acap='A';

   delay_ms(1000);
   putc(254); putc(1);
   delay_ms(10);

   while(1)
   {
      putc(acap);
      putc(254); putc(192); delay_ms(10);
      printf("ASCII %c   CHAR %d ",acap,acap);
      while(1);
        }

The LCD is the [spam] 16x2 serial LCD. When the code is executed all I get is a series of Xs on the display.

Anybody have an idea to the cause?[/quote]
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