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

Problem with wrapping lcd_putc

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



Joined: 08 Sep 2014
Posts: 20

View user's profile Send private message

Problem with wrapping lcd_putc
PostPosted: Wed Jul 29, 2015 4:51 am     Reply with quote

Hello,

I am using now a PIC16F877A and the flex_lcd driver. I am using the lcd to display a text when received one of the 14 commands that I receive from the serial port. Parsing and receiving the code isn't a problem, it works prefect.

The problem is displaying the text in the LCD. In the 14 commands I have to run some functions (disable keyboard and serial input, show the text, delay 3 seconds, reset serial input variables and display another text). Copying and pasting this into every command section is a monstrous task!!.

So I decided to make a wrapper to the run these functions. Here it is

Code:

void muestra_mensaje(char data) {
    disable_input();

    /* Limpia pantalla */
    lcd_putc("\f");

    lcd_putc(data);
   
    send_ok();
}


The problem is in lcd_putc(data);. It doesn't display the message.

Thanks for your answers
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 29, 2015 7:47 am     Reply with quote

Show us how you call the function. Post some code, including variable
declarations and initializations, that calls muestra_mensaje().
My suspicion is that you think 'char data' is a pointer and that somehow
lcd_putc() will work with a string pointer inside muestra_mensaje().
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Wed Jul 29, 2015 8:07 am     Reply with quote

As written, it'll only display one character. The single character 'data'.

I'd guess he actually wants to pass it a char array (string):
Code:

void muestra_mensaje(char * data)
{
    disable_input();

    /* Limpia pantalla */
    printf(lcd_putc,"\f%s",data);
   
    send_ok();
}   
ercarlitosg



Joined: 08 Sep 2014
Posts: 20

View user's profile Send private message

PostPosted: Sat Aug 22, 2015 4:59 am     Reply with quote

Thanks for your answers.

Here is some examples of how I call that function:
Code:

muestra_mensaje("HI");
muestra_mensaje("\nHI");


So that code doesn't work if I don't want to clear the screen.

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 22, 2015 1:45 pm     Reply with quote

Quote:
So that code doesn't work if I don't want to clear the screen.

But you can edit Ttelmah's code and remove the \f from the printf
so it becomes this:
Code:

printf(lcd_putc,"%s",data);


Also, you need to add the line shown in bold below, or it won't compile.
With the added #device statement, it displays this in MPLAB vs. 8.92 simulator:
Quote:
HI

Test program:
Quote:

#include <18F4620.h>
#device PASS_STRINGS=IN_RAM
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS)

void lcd_putc(char c)
{
putc(c);
}


void muestra_mensaje(char * data)
{
// disable_input();

printf(lcd_putc,"\f%s",data);

// send_ok();
}


//===================================
void main()
{
muestra_mensaje("HI");

while(TRUE);
}
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Sat Aug 22, 2015 1:57 pm     Reply with quote

Yes. I only added the \f, because he had it in his original code.....
ercarlitosg



Joined: 08 Sep 2014
Posts: 20

View user's profile Send private message

PostPosted: Thu Aug 27, 2015 11:58 am     Reply with quote

Sorry for my bad response. I don't know why I put that.

I refer that the code didn't worked with a constant string, but with the last response of PCM programmer It worked.

Many thanks for your help and sorry for my expression.
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