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

How to declare an array char type in a function

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



Joined: 30 Jan 2008
Posts: 197

View user's profile Send private message

How to declare an array char type in a function
PostPosted: Wed Jul 12, 2017 6:14 pm     Reply with quote

Hi, I am trying unsuccessfully to declare an array char type in a function, can someone tell me what is my error?


Code:
#include <18F4520.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOSTVREN
#use delay(clock=20MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)// RS232 Estándar

#include <stdlib.h>

#define LED             PIN_D0

#define ON                 output_high
#define OFF                output_low

int const maxLongBuffRX=42;       

char bufferRX[maxLongBuffRX];       
int indBufferRX=0x00;          
char XCommand[maxLongBuffRX];    
char flag_RptaCommand;
int i;

void Add_bufferRX(char c);

#int_rda
void serial_isr() {
  if(kbhit()){
    Add_bufferRX(getc());
  }
   flag_RptaCommand = 1;
}


void Ini_buff_rec(void){

  int i;
  for(i=0;i<maxLongBuffRX;i++){
    bufferRX[i]=0x00;
  }
  indBufferRX=0x00;
}

void Add_bufferRX(char c){

  switch(c){
    case 0x0D:
      break;
    case 0x0A:
      break;
    default:
      bufferRX[indBufferRX++]=c;
  }
}

int1 SendATCommand( char CommandTX[], char RXCommand[] ){

   Ini_buff_rec();

   for (i=0; i<strlen(strlen(XCommand)); i++){
      printf ("%c",CommandTX[i]);
   }

   
   while (   flag_RptaCommand == 0);

   strcpy( XCommand,RXCommand);
   if(strncmp(bufferRX,XCommand,strlen(XCommand)))
       return(1);   
   else
       return(0);   
}

void main(){

   OFF(LED);
   if (SendATCommand("AT", "OK")){
      ON(LED);
   }

   delay_ms(200);

while (TRUE);
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jul 12, 2017 7:31 pm     Reply with quote

Add the line shown in bold below:
Quote:
#include <18F4520.h>
#device PASS_STRINGS=IN_RAM
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT,NOSTVREN
#use delay(clock=20MHz)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)// RS232 Estándar

It should now compile OK.
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