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

Problem using LCD.c

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



Joined: 12 Oct 2010
Posts: 12
Location: South Africa

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

Problem using LCD.c
PostPosted: Wed Oct 13, 2010 12:46 am     Reply with quote

I'm using a 16x2 lcd RB0 - RB3 are used for data,
RB4 is unused, ENABLE is connected to RB5, RS is connected to RB6 and rw is connected to RB7.

The LCD does not display anything..

There is the source code.

Code:
#include <16F877A.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=4000000)

// Un-comment the following define to use port B
#define use_portb_lcd TRUE


struct lcd_pin_map {                 // This structure is overlayed
           int     data : 4;         // be pin B0.
         BOOLEAN unused;           // low order up.  ENABLE will
         BOOLEAN enable;           // on to an I/O port to gain
           BOOLEAN rs;               // access to the LCD pins.
           BOOLEAN rw;               // The bits are allocated from
        } lcd;

#locate lcd = getenv("sfr:PORTB")
#define set_tris_lcd(x) set_tris_b(x)
/*
#if defined use_portb_lcd
   #locate lcd = getenv("sfr:PORTB")    // This puts the entire structure over the port
   #ifdef __pch__
    #locate lcd = 0xf81
   #else
    #locate lcd = 6
   #endif
   #define set_tris_lcd(x) set_tris_b(x)
#else
   //#locate lcd = getenv("sfr:PORTD")    // This puts the entire structure over the port
   #ifdef __pch__
    #locate lcd = 0xf83
   #else
    #locate lcd = 8
   #endif
   #define set_tris_lcd(x) set_tris_d(x)
#endif
*/

.
.
.

int main() {
     lcd_init();
   lcd_putc("Yippee I made my LCD work!");
   return 0;   
}


++++++++++++++++++++++
Edited to remove segment of lcd.c

Reason: Forum Rule 10

10. Don't post the CCS example code or drivers, or ask for such code and drivers.

Forum rules -
http://www.ccsinfo.com/forum/viewtopic.php?t=26245

-- Forum Moderator
++++++++++++++++++++++

_________________
Regards,
Brandon
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Oct 13, 2010 2:03 am     Reply with quote

The compiler automatically puts a sleep instruction as the last instruction of main. You need to put an infinate loop in to stop the pic from going to sleep.

Also remove the return as main has nowhere to return to, Unless you are using some sort of booter.

This has been discussed many times on here:-

Code:

int main() {
     lcd_init();
   lcd_putc("Yippee I made my LCD work!");

  while(true) {}
}
siphorob



Joined: 12 Oct 2010
Posts: 12
Location: South Africa

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

PostPosted: Wed Oct 13, 2010 3:45 am     Reply with quote

Thanks Smile ,

I'll test the code.
_________________
Regards,
Brandon
siphorob



Joined: 12 Oct 2010
Posts: 12
Location: South Africa

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

PostPosted: Wed Oct 13, 2010 10:40 am     Reply with quote

Confused
The piece of code still did not work.
_________________
Regards,
Brandon
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Oct 13, 2010 11:24 am     Reply with quote

Try using the Flex lcd driver. It's much easier to get it working:
http://www.ccsinfo.com/forum/viewtopic.php?t=24661

Make sure the contrast pin on your LCD (Vo) has about 0.4 volts on it.
This contrast voltage will allow you to see characters on the LCD.
siphorob



Joined: 12 Oct 2010
Posts: 12
Location: South Africa

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

PostPosted: Wed Oct 13, 2010 1:08 pm     Reply with quote

Thank you, thank you.
The is the best fourm ever Very Happy
_________________
Regards,
Brandon
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