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

expecting an identifier ?

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



Joined: 04 Mar 2014
Posts: 2

View user's profile Send private message

expecting an identifier ?
PostPosted: Tue Mar 04, 2014 3:21 pm     Reply with quote

hi this is the first time of mine working with ccs so i needed to do a code to run a nrf24l01 on a pic16f88, when i did the emisor code , wich is similar to the receptor code (below) i didnt have any problems with the asm part code , but when i do the receptor this problem shows up "expecting an identifier" so i cut the asm part out of the code , and it comipiles fine so why it does that ? what is my error ? can you help me guys = / ?

receptor code =
Code:
#device PIC16F88
#include <16F88.h>

#fuses XT //Oscilador a cristal standar
#fuses NOWDT //sin WatchDog Timer
#fuses NOPROTECT //sin proteccion de memoria de programa
#fuses NOPUT //sin PowerUp Timer
#fuses NOBROWNOUT //sin brownout
#fuses NOLVP //sin programación en baja tensión

#use delay(clock=4000000)

#include "lib_rf2gh4_10.h" // Librería para manejar el módulo SPI con el nRF24L01.

#byte porta=0x05           // Dirección del puerto A.
#byte portb=0x06           // Dirección del puerto B.

int8 ret1;
int8 data;


#int_ext                   // Interrupción RB0/INT del módulo RF.
void int_RB0()
{
   ret1 = RF_RECEIVE();
   if ( (ret1 == 0) || (ret1 == 1) )
   {
      do
      {   
         data=RF_DATA[0];  // Data contendrá el valor que le llege del emisor, a través de RF_DATA[0].
         
            #asm         //  If i cut from here,
           
            BTFSS    data,0
            BCF      PORTA,4
            BTFSC    data,0
            BSF      PORTA,4
     
            BTFSS    data,1
            BCF      PORTB,0
            BTFSC    data,1
            BSF      PORTB,0
     
            BTFSS    data,2
            BCF      PORTB,3
            BTFSC    data,2
            BSF      PORTB,3
           
            #endasm             // To here and compile the code works fine and it compiles
           
         
         ret1 = RF_RECEIVE();
      } while ( (ret1 == 0) || (ret1 == 1) ); // Tanto si existe entrada múltiple o simple de datos los lee.
   } 
}

void main()                  //Programa principal
{
   set_tris_a(0b100000);     // RA0 sustituye a RB0 y se pone un LED en RA0.
   set_tris_b(0b00000011);   // RB0 es para la interrupción, el resto son LEDs.
   
   RF_INT_EN();              // Habilitar interrupción RB0/INT.
   RF_CONFIG_SPI();          // Configurar módulos SPI del PIC.
   RF_CONFIG(0x40,0x08);     // Configurar módulo RF (canal y dirección).
   RF_ON();                  // Activar el módulo RF.
   
   while(true);              // Bucle infinito.
       
}

 
Ttelmah



Joined: 11 Mar 2010
Posts: 19538

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 3:39 pm     Reply with quote

Start with the assembler.
Not necessary. It rarely is now with CCS:
Code:

//add after your port definitions
#bit bit0=porta.4
#bit bit1=portb.0
#bit bit2=portb.3

//Then the assembler codes as:
      bit0=bit_test(data,0);
      bit1=bit_test(data,1);
      bit2=bit_test(data,2);


Then:
Code:

      } while ( (ret1 == 0) || (ret1 == 1) );

is never going to exit. ret1, is always either 0, or 1....

Since this is in the interrupt, the code would hang (if it got to the interrupt)....

Then you never enable the interrupt, so this will never actually happen.

Then you don't show your library, but either RF_DATA is not declared, or one of the functions you call, expects an identifier passed to it, which you are missing.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 4:06 pm     Reply with quote

With regard to the asm code, the compiler doesn't like 'data'. It may be
a reserved word. Change it to 'data1' or something else, and it will
compile OK.
nahueldiaz



Joined: 04 Mar 2014
Posts: 2

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 5:19 pm     Reply with quote

PCM programmer wrote:
With regard to the asm code, the compiler doesn't like 'data'. It may be
a reserved word. Change it to 'data1' or something else, and it will
compile OK.



Thanks a lot !
luckyluke



Joined: 18 Apr 2006
Posts: 45

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 5:56 pm     Reply with quote

PCM programmer wrote:
With regard to the asm code, the compiler doesn't like 'data'. It may be
a reserved word. Change it to 'data1' or something else, and it will
compile OK.

it might be in lib_rf2gh4_10.h
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 6:06 pm     Reply with quote

That's not the reason, because the simple program below also fails.
But if you change it to data1 or some other name, then it compiles:
Code:

#include <16F88.h>
#fuses INTRC_IO, NOWDT
#use delay(clock=4M)

int8 data;

//======================
void main()     
{

#asm
BTFSS    data,0
#endasm       
   
while(1);           
}
jeremiah



Joined: 20 Jul 2010
Posts: 1354

View user's profile Send private message

PostPosted: Tue Mar 04, 2014 8:56 pm     Reply with quote

DATA is a reserved ASM command that CCS uses to setup and initialize variables. I don't think it is a microchip keyword, but a CCS ASM command.

EDIT: Here's some example code that produces the DATA keyword in the ASM

Code:

#case
#include <24FJ64GB002.h>
#FUSES NOWDT, FRC, PR_PLL, HS, CKSNOFSM, ICSP1, NOJTAG, NODEBUG

#use delay(clock=8000000,crystal=12000000)

typedef struct{
   unsigned int16 value;
   unsigned int8 test;
   unsigned int16 second;
   struct{
      int8 test;
      int8 val;
   }vals;
} stype;

#define DEFAULT_STRUCT {1,23,4056,{7,128}}

stype special[34] = {DEFAULT_STRUCT};

void main(void){
   
   while(TRUE);
}


The ASM generated in 5.019 for this is (see line 0212):
Code:

0000:  GOTO    200
.................... #case
.................... #include <24FJ64GB002.h>
.................... //////////// Standard Header file for the PIC24FJ64GB002 device ////////////////
.................... ///////////////////////////////////////////////////////////////////////////
.................... ////        (C) Copyright 1996, 2013 Custom Computer Services          ////
.................... //// This source code may only be used by licensed users of the CCS C  ////
.................... //// compiler.  This source code may only be distributed to other      ////
.................... //// licensed users of the CCS C compiler.  No other use, reproduction ////
.................... //// or distribution is permitted without written permission.          ////
.................... //// Derivative programs created using this software in object code    ////
.................... //// form are not restricted in any way.                               ////
.................... ///////////////////////////////////////////////////////////////////////////
.................... #device PIC24FJ64GB002
.................... 
.................... #list
.................... 
.................... #FUSES NOWDT, FRC, PR_PLL, HS, CKSNOFSM, ICSP1, NOJTAG, NODEBUG
.................... 
.................... #use delay(clock=8000000,crystal=12000000)
.................... 
.................... typedef struct{
....................    unsigned int16 value;
....................    unsigned int8 test;
....................    unsigned int16 second;
....................    struct{
....................       int8 test;
....................       int8 val;
....................    }vals;
.................... } stype;
.................... 
.................... #define DEFAULT_STRUCT {1,23,4056,{7,128}}
.................... 
.................... stype special[34] = {DEFAULT_STRUCT};
.................... 
.................... void main(void){
*
0200:  MOV     #2780,W15
0202:  MOV     #27FF,W0
0204:  MOV     W0,20
0206:  NOP     
0208:  BSET.B  81.7
020A:  MOV     #A0,W4
020C:  MOV     W4,744
020E:  SETM    32C
0210:  BRA     23A
0212:  DATA    80,08,08
0214:  DATA    00,01,00
0216:  DATA    17,00,D8
0218:  DATA    0F,07,80
021A:  DATA    41,08,00
021C:  DATA    00,00,00
021E:  INC     W2,W2
0220:  CP      W2,#1
0222:  BRA     NZ,22C
0224:  TBLRDL  [W1],W3
0226:  TBLRDH  [W1++],W4
0228:  MOV.B   6,W0L
022A:  RETURN 
022C:  CP      W2,#2
022E:  BRA     NZ,234
0230:  MOV.B   7,W0L
0232:  RETURN 
0234:  MOV.B   8,W0L
0236:  CLR     W2
0238:  RETURN 
023A:  MOV     #0,W6
023C:  MOV     #0,W0
023E:  MOV     W0,32
0240:  MOV     #212,W0
0242:  MOV     W0,W1
0244:  CLR     W2
0246:  CALL    21E
024A:  MOV.B   W0L,B
024C:  CALL    21E
0250:  MOV.B   W0L,A
0252:  CP0     W5
0254:  BRA     Z,288
0256:  BTSS    W5.F
0258:  BRA     268
025A:  CALL    21E
025E:  MOV.B   W0L,D
0260:  CALL    21E
0264:  MOV.B   W0L,C
0266:  BCLR    W5.F
0268:  BTSS    W5.E
026A:  BRA     27C
026C:  BCLR    W5.E
026E:  DEC     W5,W5
0270:  CALL    21E
0274:  MOV.B   W0L,W7L
0276:  REPEAT  W5
0278:  MOV.B   W7L,[W6++]
027A:  BRA     246
027C:  CALL    21E
0280:  MOV.B   W0L,[W6++]
0282:  DEC     W5,W5
0284:  BRA     NZ,27C
0286:  BRA     246
....................     
....................    while(TRUE);
0288:  BRA     288
.................... }
028A:  PWRSAV  #0

Configuration Fuses:
   Word  1L: 3F7F   WPOSTS16 WDT128 WINDIS NOWDT ICSP1 NODEBUG NOWRT NOPROTECT NOJTAG
          H: FF00 
   Word  2L: AB7E   HS NOALTI2C1 IOL1WAY NOOSCIO CKSNOFSM PR_PLL PLL96MHZ PLLDIV3 IESO
          H: FF00 
   Word  3L: FFFF   WPFP SOSC_HIGH WUT_DEFAULT WPDIS NOWPCFG WPEND
          H: FF00 
   Word  4L: FFFF   DSWDT2147483648 DSWDTCK_LPRC RTCOSC_SOSC DSBOR DSWDT
          H: FF00 
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