|
|
View previous topic :: View next topic |
Author |
Message |
josue
Joined: 28 Jan 2014 Posts: 10 Location: Venezuela
|
problem with switch case statements |
Posted: Mon Feb 03, 2014 9:19 pm |
|
|
Hi everybody.. Im trying to do a switch case statement but the compiler throws an error...
*** Error 117 "probando_uart.c" Line 142(1,2): Improper use of a function identifier
*** Error 51 "probando_uart.c" Line 144(1,5): A numeric expression must appear here
*** Error 51 "probando_uart.c" Line 167(1,5): A numeric expression must appear here
this is my code
Code: |
#include <16F877A.h>
#fuses XT, NOWDT, NOPROTECT, NOLVP
#use delay(clock=4000000)
#use rs232(UART1, baud=9600)
#define LED_ON(x) output_high(x)
#define LED_OFF(x) output_low(x)
#define ledR PIN_B1
#define ledV PIN_B0
short correcto=FALSE; //indica resultado de la suma de control
BYTE recepcionXbee[50]; //almacenamiento de las recepciones
BYTE auxRecepXbee[100]; //auxiliar para el almacenamiento de las recepciones
BYTE sumaDeControl=0;
BYTE prx=0;
int i= 0;
int a= 0;
int cuenta;
BYTE bit64dir0;
BYTE bit64dir1 ;
BYTE bit64dir2 ;
BYTE bit64dir3;
BYTE ruta= 0x00;
BYTE board;
BYTE data_out;
BYTE dimmer;
BYTE dimmer1;
BYTE tv;
BYTE checksum;
BYTE bit4_64dir;
BYTE bit5_64dir;
BYTE bit6_64dir;
BYTE bitLsb64dir ;
BYTE bitMsb16dir ;
BYTE bitLsb16dir ;
////////////////////////////////////////////
// Direccion de envio XBEE
//7E 00 12 10 01 00 13 A2 00 40 A1 21 F8 CB 97 00 00 48 4F 4C 41 9B
#define startbit 0X7E
#define tamamin 0x00
#define tamamax 0x14
#define frametype 0x10 // trasminsion
#define frametype1 0x90 // recepcion
#define frameid 0x01
#define bitMsb64dir 0x00
#define bit1_64dir 0x13
#define bit2_64dir 0xA2
#define bit3_64dir 0x00
#define broadcast_radius 0x00
#define options 0x00
#define EDR11 0x02
#define EDR12 0x02
#define EDR13 0X03
#define EDR21 0X05
#define EDR22 0X05
#define EDR23 0X06
#define EDR31 0X08
#define EDR32 0X09
#define EDR33 0X0A
#define EDR34 0X0B
//////////////////////////////////////////////////////
//
// Limpio la variable AUX RECEP
//
//
//////////////////////////////////////////////////////
void limpiarAuxRecep(void)
{
int t=0;
do{auxRecepXbee[t++]=0;}
while(t<=99);
}
//////////////////////////////////////////////////////
//
// Limpio la variable RECEP
//
//
//////////////////////////////////////////////////////
void limpiarRecepcion()
{
int t=0;
do {recepcionXbee[t++]=0;}while(t<=49);
i=0;
}
//////////////////////////////////////////////////////
//
// paso valores de recepcionXbee a AuxrecepcionXBEE
//
//
//////////////////////////////////////////////////////
void pasar_auxRecepcionXbee(){
if(recepcionXbee[0] != 0){
for( a = 0; a<= i; a++){
auxRecepXbee[a] = recepcionXbee[a];
}
limpiarRecepcion();
}
}
//////////////////////////////////////////////////////
//
// asses data
//
//
//////////////////////////////////////////////////////
void digiero_data(){
if((auxRecepXbee[0]== startbit)&& (auxRecepXbee[1]== tamamin) && (auxRecepXbee[2] == 0x12) && (auxRecepXbee[3]== frametype1)){
bit64dir0 = auxRecepXbee[8];
bit64dir1 =auxRecepXbee[9];
bit64dir2 = auxRecepXbee[10];
bit64dir3 =auxRecepXbee[11];
ruta =auxRecepXbee[15];
board =auxRecepXbee[16];
data_out =auxRecepXbee[17];
dimmer =auxRecepXbee[18];
dimmer1 =auxRecepXbee[19];
tv =auxRecepXbee[20];
}
//////////////////////////////////////////////////////
//
// veo hacia donde transmito
//
//
//////////////////////////////////////////////////////
void donde_transmitir(){
switch(ruta){
case EDR11:
if(board == 0x09){
bit4_64dir= 0xFF; /////////////////////////
bit5_64dir=0xFF; // Direccion baja de 64 bits del Xbee asociado a la board 0x09 "EDR1-D1"
bit6_64dir=0xFF; //
bitLsb64dir=0xFF; ////////////////////////
bitMsb16dir=0xFF; //
bitLsb16dir=0xFF; //Direccion de 16bits del Xbee asociado a la board 0x09 "EDR1-D1"
checksum = 0xFF - (frametype + frameid + bitMsb64dir + bit1_64dir + bit2_64dir + bit3_64dir + bit4_64dir + bit5_64dir + bit6_64dir + bitLsb64dir + bitMsb16dir + bitLsb16dir + broadcast_radius + options + board + ruta + data_out + dimmer + dimmer1+ tv);
putc(startbit); putc(tamamin); putc(tamamax);putc(frametype);
putc(frameid);putc(bitMsb64dir);putc(bit1_64dir);putc(bit2_64dir);
putc(bit3_64dir);putc(bit4_64dir);putc(bit5_64dir);putc(bit6_64dir);
putc(bitLsb64dir);putc(bitMsb16dir);putc(bitLsb16dir);putc(broadcast_radius);
putc(options);putc(ruta);putc(board);putc(data_out);putc(dimmer);putc(dimmer1);
putc(tv);putc(checksum);
}
break;
case EDR12:
if(board = 0x09){
bit4_64dir= 0xFF; /////////////////////////
bit5_64dir=0xFF; // Direccion baja de 64 bits del Xbee asociado a la board 0x09 "EDR1-D1"
bit6_64dir=0xFF; //
bitLsb64dir=0xFF; ////////////////////////
bitMsb16dir=0xFF; //
bitLsb16dir=0xFF; //Direccion de 16bits del Xbee asociado a la board 0x09 "EDR1-D1"
checksum = 0xFF - (frametype + frameid + bitMsb64dir + bit1_64dir + bit2_64dir + bit3_64dir + bit4_64dir + bit5_64dir + bit6_64dir + bitLsb64dir + bitMsb16dir + bitLsb16dir + broadcast_radius + options + board + ruta + data_out + dimmer + dimmer1+ tv);
putc(startbit); putc(tamamin); putc(tamamax);putc(frametype);
putc(frameid);putc(bitMsb64dir);putc(bit1_64dir);putc(bit2_64dir);
putc(bit3_64dir);putc(bit4_64dir);putc(bit5_64dir);putc(bit6_64dir);
putc(bitLsb64dir);putc(bitMsb16dir);putc(bitLsb16dir);putc(broadcast_radius);
putc(options);putc(ruta);putc(board);putc(data_out);putc(dimmer);putc(dimmer1);
putc(tv);putc(checksum);
}
break;
}
}
void main(void) {
enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);
char c;
while(1)
{
pasar_auxRecepcionXbee();
if(auxRecepXbee[0] != 0){
for(a=0;a<=i;a++){
putc(auxRecepXbee[a]);
}
limpiarAuxRecep();
a=0;
}
}
}
#INT_RDA
void recepcionSerie(void)
{
recepcionXbee[i]= getc();
i++;
}
|
im working with Xbee modules.. the problem appears when i try to compare the variable RUTA with a switch case...
RUTA is a byte
the cases would be EDR11, EDR12, EDR13..... these are bytes too.
Any help??
Thanks |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Mon Feb 03, 2014 10:20 pm |
|
|
Quote: | void digiero_data(){ |
Look carefully at this function. You're missing a brace. |
|
|
josue
Joined: 28 Jan 2014 Posts: 10 Location: Venezuela
|
|
Posted: Wed Feb 05, 2014 7:55 am |
|
|
Thank you, thank you, thank you very much PCM programmer... very helpfull... |
|
|
|
|
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
|