|
|
View previous topic :: View next topic |
Author |
Message |
pilar
Joined: 30 Jan 2008 Posts: 197
|
How to declare an array char type in a function |
Posted: Wed Jul 12, 2017 6:14 pm |
|
|
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
|
|
Posted: Wed Jul 12, 2017 7:31 pm |
|
|
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. |
|
|
|
|
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
|