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 using PIC16F874

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







LCD using PIC16F874
PostPosted: Thu Mar 16, 2006 9:12 am     Reply with quote

hello,
Wireless receiver sends this 8 bit parallel input to PIC16F874 chip and this is to displayed on 2*16 HD44780 LCD display.

I will be really grateful if someone can help me do the coding for the PIC chip which recieves 8 bit parallel input and displays it on HD44780 LCD(especially main() to receive input and display it on LCD)
Sincerely,
Rahul
rberek



Joined: 10 Jan 2005
Posts: 207
Location: Ottawa, Canada

View user's profile Send private message

PostPosted: Thu Mar 16, 2006 9:24 am     Reply with quote

There are literally dozens of examples of interfacing that family of PIC to that Hitachi LCD controller scattered around this forum, as well as example driver code in the CCS directory.
sjbaxter



Joined: 26 Jan 2006
Posts: 141
Location: Cheshire, UK

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

PostPosted: Thu Mar 16, 2006 9:26 am     Reply with quote

As a starting point, show us what you have done upto now and then we will look at it and give you some advice. As you may already have seen (by searching this forum) you will not get any help writing code, unless you make some kind of effort first !!

This is NOT a forum for getting someone else to write code for you, but to assist you in fixing problems or discussing code that you have already started to develop.

Your request seems like you have an idea what you want but you just want someone else to do all the work !! I'm afraid this is the wong place for such requests.
_________________
Regards,
Simon.
rahul
Guest







this is what i have done till now
PostPosted: Thu Mar 16, 2006 9:57 am     Reply with quote

#include <16F874.H>
#fuses XT,NOPROTECT,NOWDT,NOLVP,PUT
#use delay(clock=20000000)


// LCD Data Management

struct lcd_pin_map {
short int enable;
short int rs;
short int rw;
short int unused;
int data:4;
}lcd;


//Variable Declarations

byte number;
long int ADC_Num;
long int value;
long int count;
long int sum;
long int Num_Output;
float voltage;
short reset_mode;
long int five_second;

// Interrupt Setup for Click-Button Reset

#INT_EXT
void ext_isr()
{
static short button_pressed=FALSE;

if(!button_pressed) // if button action and was not pressed
{
button_pressed=TRUE; // the button is now down
reset_mode=TRUE; // activate reset
ext_int_edge(L_TO_H); // change so interrupts on release
}
else // if button action and was pressed
{
button_pressed=FALSE; // the button is now up
reset_mode=FALSE; // reset reset flag
ext_int_edge(H_TO_L); // change so interrupts on press
}
if(!input(PIN_B0)) // keep button action sychronized wth button flag
button_pressed=TRUE;
delay_ms(100); // debounce button
}



#byte lcd = 7 // LCD is connected to port C
#define lcd_type 2
#define lcd_line_two 0x40 // LCD RAM address for the second line

int CONST LCD_INIT_STRING[4] = {0x20 | (lcd_type << 2), 0xc, 1, 6};

STRUCT lcd_pin_map const LCD_WRITE = {0, 0, 0, 0, 0};
STRUCT lcd_pin_map const LCD_READ = {0, 0, 0, 0, 15};

int lcd_read_byte()
{
int low, high;
set_tris_c(LCD_READ);
lcd.rw = 1;
delay_cycles(1);
lcd.enable = 1;
delay_cycles(1);
high = lcd.data;
lcd.enable = 0;
delay_cycles(1);
lcd.enable = 1;
delay_us(1);
low = lcd.data;
lcd.enable = 0;
set_tris_c(LCD_WRITE);
return ((high << 4) | low);
}


void lcd_send_nibble(int n)
{
lcd.data = n;
delay_cycles(1);
lcd.enable = 1;
delay_us(2);
lcd.enable = 0;
}


void lcd_send_byte(int address, int n)
{
lcd.rs = 0;
while (bit_test(lcd_read_byte(), 7));
lcd.rs = address;
delay_cycles(1);
lcd.rw = 0;
delay_cycles(1);
lcd.enable = 0;
lcd_send_nibble(n >> 4);
lcd_send_nibble(n & 0xf);
}


void lcd_init()
{
int i;
set_tris_c(LCD_WRITE);
lcd.rs = 0;
lcd.rw = 0;
lcd.enable = 0;
delay_ms(15);
for (i = 1; i <= 3; ++i)
{
lcd_send_nibble(3);
delay_ms(5);
}
lcd_send_nibble(2);
for (i = 0; i <= 3; ++i)
lcd_send_byte(0, LCD_INIT_STRING[i]);
}


void lcd_gotoxy(int x, int y)
{
int address;
if (y != 1)
address = lcd_line_two;
else
address = 0;
address += x - 1;
lcd_send_byte(0, 0x80 | address);
}

void lcd_putc(char c)
{
switch (c) {
case '\f':
lcd_send_byte(0, 1);
delay_ms(2);
break;

case '\n':
lcd_gotoxy(1, 2);
break;

case '\b':
lcd_send_byte(0, 0x10);
break;

default:
lcd_send_byte(1, c);
break;

}
}


#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP


void main()
{
lcd_init();

printf(lcd_putc, "Hello World");

while(1);
}

HERE ARE MY PIC PINS:
PIN1:GROUND
PIN2:5V
pin3:POTENTIOMETER
PIN4 TO PIN 16 OF PIC 16F874
PIN5 TO PIN 17
PIN6 TO PIN 15
PIN 11 TO PIN 23
PIN 12 TO PIN24
PIN13 TO PIN 25
PIN 14 TO PIN 26
MY LCD JUST CONTRASTS IT DOESNOT SHOW ANY MESSAGE
DATA SHEET FOR PIC: http://ww1.microchip.com/downloads/en/devicedoc/30292c.pdf
I want to receive 8 bit parallel input and display it.
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