![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
JAM2014
Joined: 24 Apr 2014 Posts: 138
|
Passing a string to a subroutine and parsing it.... |
Posted: Fri May 01, 2015 1:09 pm |
|
|
Hi All,
I want to send a string to a subroutine like this:
Code: |
Display_4D_Text("Hello World");
|
and then parse it character by character to send the data to a serially connected LCD module. So far, I have got it working.....
Code: |
void Display_4D_Text(Char InString)
{
int8 iIndex = 0;
// Here we send the character string command....
fputc(0x00,LCD_Display);
fputc(0x06,LCD_Display);
for ( iIndex=0 ; iIndex<strlen(InString) ; iIndex++ )
{
fputc(InString[iIndex],LCD_Display);
}
//Here we tell the display 'that's it...'
fputc(0x00,LCD_Display);
}
|
Thanks,
Jack |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri May 01, 2015 1:55 pm |
|
|
Quote: | So far, I have got it working..... |
I didn't see that it was working. Your code required a couple changes
to make it work, as shown in bold below.
Quote: |
#include <18F4520.h>
#device PASS_STRINGS=IN_RAM
#fuses INTRC_IO, BROWNOUT, PUT, NOWDT
#use delay(clock=4M)
#use rs232(baud=9600, UART1, ERRORS, stream=LCD_Display)
#include <string.h>
void Display_4D_Text(Char *InString)
{
int8 i;
for(i=0; i < strlen(InString); i++)
{
fputc(InString[i], LCD_Display);
}
}
//=================================
void main()
{
Display_4D_Text("Hello World");
while(TRUE);
}
|
I cut out that parts of your code that I didn't need for the test program,
and I simplified your index variable name. |
|
![](templates/subSilver/images/spacer.gif) |
JAM2014
Joined: 24 Apr 2014 Posts: 138
|
|
Posted: Fri May 01, 2015 2:19 pm |
|
|
Hi,
Sorry, that should have read:
Quote: |
So far, I haven't got it working.....
|
I had tried adding the '*' previously, and figured it should have worked fine like that. What I missed was this:
Code: |
#device PASS_STRINGS=IN_RAM
|
It's now working like a champ!
Thanks!!
Jack |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|