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_getc returns nothing

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



Joined: 12 Feb 2009
Posts: 12
Location: cape town

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

lcd_getc returns nothing
PostPosted: Tue Jul 07, 2009 7:18 am     Reply with quote

Hey all

I'm using a keypad and lcd display with a pic 877. The keypad section works and the lcd works too except when I do the lcd_getc function, it just returns a cursor character. I sort of modified the LCD.c driver to work on port_d and it works but I think maybe I'm missing something with the getc function. Here is the lcd driver code.

Code:

////////////////////////////////////////////////////////////////////////////
////                             LCD420.C                               ////
////            Driver for common 4x20 LCD modules                      ////

++++++++++++++++++
Code deleted.
Reason: Forum Rule #10
10. Don't post the CCS example code or drivers

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

And in my main, when the following function is called, The lcd has characters at the location but nothing gets returned



Code:

void calculate()
{delay_ms(50);
      agetenschar=lcd_getc(8,2);//It doesnt return this char when there is a character at that position
      agetens=agetenschar-'0';  //convert asci to integer
     // agetens=agetens*10;
      //ageunitsk=lcd_getc(9,2);
      ageunits=ageunitsk-'0';
     // ageunits=ageunits*1;
      //age=agetens+ageunits;
      //calcage=age*2;
printf(lcd_putc"\f");
lcd_gotoxy(1,1);
printf(lcd_putc"agetenschar=%c",agetenschar);
lcd_gotoxy(1,2);
printf(lcd_putc"agetens=%d",agetens);

}

When i simulate in proteus, i get an error msg stating that the hd44780 driver was busy while trying to read

Has anyone ever had this problem before?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Jul 07, 2009 1:07 pm     Reply with quote

Because you're using Proteus (and most of us don't have it), there is no
way for us to read the data sheet on the LCD simulation. Or if there was,
how do we know what version of the LCD simulation you have ? Some
versions might not support reading the LCD.

Also, your test program is too complicated. To test the lcd_getc()
function, you should have a very short program in main() that sets
the cursor to (1,1), and writes a character there, such as 'A'. Then
call lcd_getc(1,1) to read it. Display the character that was read on
a terminal window using the PIC's UART. Make sure you put a while(1)
statement at the end of main() to prevent the PIC from going to sleep.
aasief



Joined: 12 Feb 2009
Posts: 12
Location: cape town

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

Solved it
PostPosted: Wed Jul 08, 2009 2:43 am     Reply with quote

I solved it,
I just had to test the busy flag on the lcd with a
Code:

char lcd_getc( BYTE x, BYTE y) {
   char value;

    lcd_gotoxy(x,y);

    while ( bit_test(lcd_read_byte(),7) ); // wait until busy flag is low
    lcd.rs=1;
    value = lcd_read_byte();
    lcd.rs=0;
    return(value);


Thanks anyway PCM
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