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

Error 27 and 88

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



Joined: 25 Jul 2009
Posts: 2

View user's profile Send private message

Error 27 and 88
PostPosted: Sat Jul 25, 2009 6:19 pm     Reply with quote

Hello, I am trying to compile my code but I have 2 error that I can't solve.

Error 27 "xx.c" Line 93 - expression must evaluate to a constant mrx_buffer2

and

Error 88 "xx.c" Line 351 - undefined label that was used in GOTO > mrx_chk_buf

The last code line used is 349. I check there is not code below the end of the main.

Some help please Rolling Eyes
Code:

// Programa para recibir por RF 2 bytes aplicando codificacion Manchester
// Modificado a partir del codigo de el@jap.hu | http://jap.hu/electronic/
// pin TX RB1 (pin 7) 0x06,1

#include<18f452.h>
#use delay (clock=4000000)
#FUSES NOWDT, WDT128, XT, NOPROTECT, NOOSCSEN, BROWNOUT, BORV20, NOPUT, STVREN,
#FUSES NODEBUG, LVP, NOWRT, NOWRTD, NOWRTB, NOWRTC, NOCPD, NOCPB, NOEBTR, NOEBTRB

#byte pc=0xF82   // PUERTO C
#bit RX=pc.3     // entrada para el receptor de RF

// Constantes

#define EXPIRE_TIMER = 0x12
#define LATCH_MASK = 0xff
#define VALID_BIT = 0x4
#define hdrcntmin = 0x0c            // minimum number of header bits to receive
#define hdrcntmax = 0x10            // maximum number of header bits to receive

// decoder time tolerances are set at : 0.5T, 1.5T, 2.5T
// measured in 9xinstr.time (9usec) counts

#define T = 0x27                 // (d'27') half frame 350 usec (= T * 9 usec)
#define min_t = T/2              // half frame (T) minimum time
#define min_2t = 3*T/2   // half frame (T) maximum time and full frame (2T) minimum time
#define max_2t = 5*T/2           // full frame (2T) maximum time

#define packet_len = 3      // packet length, check var. alloc!
#define mrx_packet_len = 3    // packet length, check var. alloc!

// normal decoder logic input
//#define    SKL       btfsc
//#define    SKH       btfss

// FLAGS
int8 flags;                  //decode logic status
#bit IF_SHORT = flags.0
#bit FIRST_HALF = flags.1
#bit HEADER = flags.2
#bit VALID = flags.7

#define if_short_val= 1         // bit value of IF_SHORT flag
#define first_half_val= 2       // bit value of FIRST_HALF flag

//Variables

int8 bitcnt;     
int8 tmrval;          // timer value
int8 bt;          // receive byte buffer
//int8 flags           ; decode logic status
int8 btcnt;          // byte counter

int8 mrx_buffer;       // receive address buffer
int8 mrx_buffer1;      // receive packet buffer
int8 mtx_buffer2;
int8 mrx_bsum;      // receive buffer, checksum

int8 count;         // used in looping routines
int8 count1;         // used in delay routine
int8 counta;         // used in delay routine
int8 countb;         //  used in delay routine

int8 tmp1;         // temporary storage
int8 tmp2;
int8 Xmit_Byte;           // holds byte to xmit
int8 Rcv_Byte;           // holds received byte
int8 Bit_Cntr;           // bit counter for RS232
int8 Delay_Count;           // delay loop counter

int8 temp_ext_LSB, temp_ext_MSB;

// void temp_ext_low (void);
void main (void)
{

#asm
loop:     
      call    mrx_receive      // get packet
      andlw    0xff
      bnz    loop         // reject if error code
!!!!!!!!!!!!!!!!!      call    mrx_chk_buf      // test the checksum value <-- label from ERROR 88
      andlw    0xff
      bnz    loop         // reject packet if checksum fails

      movlw   0xAA         // check that packet address is correct (0xAA)
      subwf    (mrx_buffer), W
      bnz    loop         // else reject packet

// tienen cambiado mrx_buffer+1 por mrx_buffer1
      movf   mrx_buffer1,0      // get data byte byte
      movwf  temp_ext_LSB     // el 1 es x nose q cosa de los bancos :p
!!!!!!!!!!!!      movf   mrx_buffer2,0       // get data byte byte  <-- ERROR 27
      movwf  temp_ext_MSB

// seria goto fin, pero estaria bueno,enviar 3 veces el codigo y leerlo 3 veces
// y compararlos dsp para estarseguro q llegan bien, en lugar del final un loop
// 3 veces o englobar todo con un for idem en en emisor
      goto  final // loop         // just display the bytes
     
// receive routines

mrx_receive:                        // receive a full manchester-encoded packet
s3:                                 // set flags: first_half=1, if_short=0
         bsf    FIRST_HALF
s4:      bcf    IF_SHORT

s5:                                 // init before the received packet
                                    // set FSR to buffer start
      movlw    mrx_buffer
      movwf    FSR
                                    // set byte counter
      movlw    (packet_len+1)       // bytes / packet
      movwf    btcnt
                                    // set header receive mode
      bsf    HEADER
      clrf   bitcnt                 // counting bit1-s in this mode

s2:                                 // wait for a pulse
      btfss    RXBIT
      goto    s2

s6:                               // wait for end of (short) pulse up to min_2t
           clrf    tmrval
s6_w:      btfss    RXBIT
           goto    s7             // goto s7 at end of pulse

          incf    tmrval, F
           nop
          movlw    min_2t
            subwf    tmrval, W
            btfss    STATUS, C
            goto    s6_w

                               // timeout, exit
          retlw    1           // illegal startbit

s7:                            // start timer
      clrf    tmrval

s8:                           // if (if_short & rxbit) goto s9
                             // if (!if_short & !rxbit) goto s9
                             // goto s10

      btfsc    IF_SHORT
                              // if_short = 1
      goto    s8_ss1

s8_ss0:                        // if_short = 0
           btfsc    RXBIT
           goto    s10       // rxbit = 1, goto s10

s9_ss0:                         // if (timer > max_2t) exit - else goto s8
      movlw    max_2t
      subwf    tmrval, W
      btfsc    STATUS, C
      retlw    2                   // signal too long

      incf    tmrval, F
      goto    s8_ss0

s8_ss1:                             // if_short = 1
      btfss    RXBIT
      goto    s10                   // rxbit = 0, goto s10

s9_ss1:                               // if (timer > max_2t) exit - else goto s8
      movlw    max_2t
      subwf    tmrval, W
      btfsc    STATUS, C
      retlw    2                      // signal too long

      incf    tmrval, F
      goto    s8_ss1

s10:                                  // invert if_short
      movlw    if_short_val
      xorwf    flags, F

s11:                                  // if (timer < min_t) exit
      movlw    min_t
      subwf    tmrval, W
      btfss    STATUS, C
      retlw 3                         // signal too short

s12:                                 // if (timer < min_2t) goto s14
      movlw    min_2t
      subwf    tmrval, W
      btfss    STATUS, C
      goto    s14

s13:                               // if (first_half = 0) goto s16 - else exit
      btfss    FIRST_HALF
      goto    s16
      retlw    4                   // no mid-frame transition/out of sync

s14:                              // invert first_half
      movlw    first_half_val
      xorwf    flags, F

s15:                               // if (first_half = 1) goto 7
      btfsc    FIRST_HALF
      goto    s7

s16:                                // if_short is a decoded bit. Handle here
      btfss    HEADER
      goto    s16_not_header

                                    // header receiving mode
      btfss    IF_SHORT
      goto    s16_header_end

                                     // header bit is 1
      btfss    bitcnt, 4             // inc up to 16
      incf    bitcnt, F              // 16 is enough...

#ifdef NOMAXHDR
                                     // test for max header length
      movlw    hdrcntmax
      subwf    bitcnt, W
      btfss    STATUS, C
#endif
      goto    s7                    // loop back
      retlw    9                    // header too long

s16_header_end:                      // header ends indicated by a 0
      bcf    HEADER

                                     // test for min header length
      movlw    hdrcntmin
      subwf    bitcnt, W
      btfss    STATUS, C
      retlw    0x0a                  // header too short

next_byte:   movlw    0x0a
      movwf    bitcnt
      goto    s7                     // loop back

s16_not_header:                       // receiving bytes
      decf    bitcnt, F
      bz    s16_s4                    // if (bitcnt = 0) check for a byte-sep 1

      // if (bitcnt = 1) check for a byte-separator 0
      movlw    1
      xorwf    bitcnt, W
      bnz    s16_s2

      // test for a byte separator 1
      btfsc    IF_SHORT
      goto    s7
      retlw    7                  // byte-ending 1 not present

s16_s2:      // bit is data

      rrf    flags, W
      rlf    bt, F
      goto    s7

s16_s4:      // check for a byte-separator 0
      btfsc    IF_SHORT
      retlw    8       // byte-ending 0 not present

      // OK, received byte is sane, store in buffer
      movf    bt, W
      movwf    INDF
      incf    FSR, F

      decfsz    btcnt, F
      goto    next_byte

      retlw    0       // OK, buffer received

      // buffer checking is not done automatically!
      // if returned value is 0, call mrx_chk_buf to check
      //

!!!!!!!!!!!!! mrx_chk_buf:        // check buffer sanity by chksum  <-- label from error 88

      movlw    mrx_buffer
      movwf    FSR
      movlw    (packet_len+1) // number of bytes with the chksum byte
      movwf    btcnt
      movlw    0xff
      movwf    bt // used as sum register

chk0:      movf    INDF, W
      // fast CRC-8 algorithm with poly x^8+x^5+x^4+1
      // executes in 23 cycles per update
      xorwf   bt,f
      clrw
      btfsc   bt,7
      xorlw   0x7a
      btfsc   bt,6
      xorlw   0x3d
      btfsc   bt,5
      xorlw   0x86
      btfsc   bt,4
      xorlw   0x43
      btfsc   bt,3
      xorlw   0xb9
      btfsc   bt,2
      xorlw   0xc4
      btfsc   bt,1
      xorlw   0x62
      btfsc   bt,0
      xorlw   0x31
      movwf   bt

      incf    FSR, F
      decfsz    btcnt, F
      goto    chk0
      // correct checksum must be zero
      movf    bt, W
      bnz    chk_err
      retlw    0       // result is in Z
chk_err:      retlw    0x0c       // checksum error

mrx_init:   return

// delay routines

Delay255:   movlw   0xff         //delay 255 mS
             goto   d0
Delay100:   movlw   0x64     //d'100'         //delay 100mS
              goto   d0
Delay50:      movlw   0x32   //d'50'         //delay 50mS
             goto   d0
Delay20:      movlw  0x14    //d'20'         //delay 20mS
            goto   d0
Delay5:      movlw   0x05         //delay 5.000 ms (4 MHz clock)
d0:           movwf   count1
d1:            movlw   0xC7         //delay 1mS
            movwf   counta
            movlw   0x01
            movwf   countb
Delay_0:
            decfsz   counta, f
          goto   delay_01
            decfsz   countb, f
delay_01:   goto   Delay_0

            decfsz   count1   ,f
            goto   d1
            retlw   0x00

final: NOP   

#endasm
 
}
Confused Confused Confused
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

PostPosted: Sat Jul 25, 2009 7:03 pm     Reply with quote

Unless I am missing it somewhere mrx_buffer2 is not defined, mTx_buffer2 is defined.
_________________
Google and Forum Search are some of your best tools!!!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 25, 2009 9:14 pm     Reply with quote

Quote:
define EXPIRE_TIMER = 0x12
#define LATCH_MASK = 0xff
#define VALID_BIT = 0x4
#define hdrcntmin = 0x0c // minimum number of header bits to receive
#define hdrcntmax = 0x10 // maximum number of header bits to receive

There are no equal signs in #defines.
ralcesar



Joined: 25 Jul 2009
Posts: 2

View user's profile Send private message

PostPosted: Sun Jul 26, 2009 11:11 am     Reply with quote

Thanks. I change those mistakes and some others and now its working Very Happy
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