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

displaying values on LCD

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







displaying values on LCD
PostPosted: Fri Feb 27, 2009 2:46 pm     Reply with quote

I have a PIC 18f4520 that i am using with the PICDEM 2 Plus demo board, the Rohs version. I can output stand text, but now I want to output a value.
Code:

#include <18F4520.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)

#define LCD_POWER  PIN_D7

#include "Flex_LCD.c"

int num = 0;

//============================
void main()
{
   output_high(LCD_POWER);  // Turn on power to LCD
   output_low(LCD_RW);      // Set R/W pin on LCD to a low level

   lcd_init();              // Initialize the LCD

   lcd_putc('\f');

   while(true);
   {
      lcd_putc(num);
      delay_ms(250);
      num++;
   }
}
Ttelmah
Guest







PostPosted: Fri Feb 27, 2009 2:55 pm     Reply with quote

'num', is a binary value, starting at 0, and incrementing by one each time round the loop. 'putc', outputs a _single_ character. So, your code will print every possible character from 0 to 255.
Look at 'printf', which converts values into their ASCII format for output.
printf("%d\n\r",num);

Read the manual to work out what the other characters here are doing.

Best Wishes
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Feb 27, 2009 3:07 pm     Reply with quote

Also, please don't start a new thread every time you have a new question
about displaying characters on an LCD. You already have an existing
thread on the topic, here:
http://www.ccsinfo.com/forum/viewtopic.php?t=37985
You can add new questions to the existing thread.
Guest








PostPosted: Fri Feb 27, 2009 3:50 pm     Reply with quote

I tried the printf command but it is still not working. When I tried the printf it gave me the error STDOUT not defined (may be missing #use rs232). I know C and C++ programming so I understand what the notations are doing, I'm just new to this compiler and just need to get use to it.

Code:
#include <18F4520.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#define LCD_POWER  PIN_D7

#include "Flex_LCD.c"
#use  rs232           //Do I need this

int num = 0;

//============================
void main()
{
   output_high(LCD_POWER);  // Turn on power to LCD
   output_low(LCD_RW);      // Set R/W pin on LCD to a low level

   lcd_init();              // Initialize the LCD

   lcd_putc('\f');

   while(true);
   {
      printf("%d\n\r",num);
      delay_ms(250);
      num++;
   }
}
Ttelmah
Guest







PostPosted: Fri Feb 27, 2009 3:52 pm     Reply with quote

As I said, _read the manual_.
By default, all commands talk to STDIO. You want to talk to lcd_putc. Look at the entry for printf, and it shows how to do this.

Best Wishes
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