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

16F877 Problem - passing string data

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



Joined: 01 Oct 2008
Posts: 4
Location: England (for time being)

View user's profile Send private message

16F877 Problem - passing string data
PostPosted: Tue Nov 25, 2008 7:28 am     Reply with quote

I'm having a problem with sending some sample data to test a microcontroller - the data is passed via a 16F877 and the
character strings dont get passed from the sample data array.

Here is the code.

Code:
/***********************************/
/* PROGRAM    SIMULATE STREAM        */
/***********************************/
#include    <16F877.h>
#device    ICD=TRUE
#device   PASS_STRINGS=IN_RAM
#fuses      HS, NOWDT, BROWNOUT, NOPROTECT, PUT
#use    delay(clock=20000000)
#use    rs232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, STREAM=SIMOUT, ERRORS)

#define RED_LED      PIN_D0            
// Placing strings in ROM
#define   MAXDATA      23

typedef   unsigned int UINT8   ;

// Heres the test data
const char *sdata[]=  {      "00:24:35 0980200,",
                  "00:24:37 0980000,",
                  "00:24:53 0980000,",
                  "555555  ,",
                  "00:26:16 0980200,",
                  "00:27:16 0980200,",
                  "00:28:16 0980200,",
                  "4523    ,",
                  "00:29:28 0980380,",
                  "00:30:28 0980200,",
                  "00:31:28 0980200,",
                  "00:32:28 0980200," 
                  "00:33:28 0980200,",
                  "00:34:28 0980200,",
                  "00:35:28 0980200,",
                  "00:36:28 0980200,",
                  "00:37:28 0980200,",
                  "00:38:28 0980200,",
                  "00:39:28 0980200,",
                  "00:40:28 0980300,",
                  "00:41:28 0980300,",
                  "00:42:28 0980200,",
                  "00:43:28 0980200,"    };
void main(void)
{   
UINT8 counter = 0;
fprintf(SIMOUT, "\r\nSTARTING TELEMETRY SIM.\r\n");      
fprintf(SIMOUT, "Sending test data in 1 second ..........\r\n");
delay_ms(1000);
while(TRUE)   {   
   fprintf(SIMOUT, "String: %s", sdata[counter++]);
   delay_ms(600);
   if (counter >= 22) counter = 0;
   output_toggle(RED_LED);
   delay_ms(1000);
   }
}

_________________
Thanks in advance ...
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 25, 2008 2:12 pm     Reply with quote

In the 16F PICs (with the PCM compiler), there is a limit of 256 bytes
per 'const' array. If you break up the array into two pieces, then it
works. Example:
Code:
#include <16F877.h>
#device *=16
#device PASS_STRINGS=IN_RAM
#fuses HS, NOWDT, BROWNOUT, NOPROTECT, PUT
#use delay(clock=20000000)
#use rs232(BAUD=9600, XMIT=PIN_C6, RCV=PIN_C7, ERRORS)


char const sdata_1[14][18]=
 {
                  "00:24:35 0980200,",
                  "00:24:37 0980000,",
                  "00:24:53 0980000,",
                  "555555          ,"  ,
                  "00:26:16 0980200,",
                  "00:27:16 0980200,",
                  "00:28:16 0980200,",
                  "4523            ,",
                  "00:29:28 0980380,",
                  "00:30:28 0980200,",
                  "00:31:28 0980200,",
                  "00:32:28 0980200,", 
                  "00:33:28 0980200,",
                  "00:34:28 0980200,"
};                 

char const sdata_2[9][18]=
 {
                  "00:35:28 0980200,",
                  "00:36:28 0980200,",
                  "00:37:28 0980200,",
                  "00:38:28 0980200,",
                  "00:39:28 0980200,",
                  "00:40:28 0980300,",
                  "00:41:28 0980300,",
                  "00:42:28 0980200,",
                  "00:43:28 0980200,"   
 
};


void main(void)
{   
int8 i;
printf("Start\n\r");
for(i = 0; i < 14; i++)
    printf("%s\n\r", sdata_1[i]);

for(i = 0; i < 9; i++)
    printf("%s\n\r", sdata_2[i]);


}
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