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

Send data through variable for LCD?

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



Joined: 24 Mar 2014
Posts: 7

View user's profile Send private message

Send data through variable for LCD?
PostPosted: Sun Mar 30, 2014 3:20 pm     Reply with quote

I want to send data through variable through LCD.
and I am using flex_lcd drive.
my LCD is struck, and the pin c6 get high.
Code:
 
#include <18F4520.h>
#FUSES NOPROTECT,NOWDT,NOLVP,HS,NOBROWNOUT
#use delay(clock=10000000)
#include <flex_lcd.h>
float phase_angle = 13.6;
float firing_angle = 10.5;
int cap_bnk=12;
void main()
{
      lcd_init();
      while(1)
      {
      sprintf(LCD_putc,"\f %u",phase_angle);
      delay_ms(100);
       lcd_gotoxy(0,1);
       sprintf(LCD_putc,"FA:%u",firing_angle);
       delay_ms(100);
       lcd_gotoxy(0,2);
       sprintf(LCD_putc, "Cap:%u",cap_bnk); 
       delay_ms(100);     
      }
}


I tried fprintf,sprintf and printf. I heard that these are UART functions.
please help
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Mar 30, 2014 3:51 pm     Reply with quote

Read the CCS manual. Or just google sprintf. You are 2nd person within
a short time period who uses sprintf incorrectly. The output of sprintf
goes to a RAM buffer. It never goes to an i/o function or a stream.
For that, you should use printf.

Also, read the CCS manual for printf. %u is not the format specifier
for a floating point variable. The manual (in the printf section) will
tell you what the correct format specifier is.
http://www.ccsinfo.com/downloads/ccs_c_manual.pdf

Even one more thing !
You are using 0 as a parameter in the lcd_gotoxy() function. But the
function specification given in the CCS driver file, lcd.c, does not say you
can do that. It say this:
Quote:
lcd_gotoxy(x,y) Set write position on LCD (upper left is 1,1)


You need to read the documentation for every function before you use 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