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

A numeric expression must appear here: error

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



Joined: 07 Jan 2010
Posts: 4

View user's profile Send private message

A numeric expression must appear here: error
PostPosted: Wed Jan 20, 2010 11:31 pm     Reply with quote

CCS PCM C Compiler, Version 4.057
PIC16F886

Code:

int16 t1;  //is defined up at the top of the main loop

//this is from the main loop

      if (data_flag) {
         printf("data_flag triggered\n\r");
         if (data_collected <= max_data) {
            if (packet_index < sizeof(packet0)) {
               for(k = 0; k <= (active_channels-1); k++) {
                  set_mux_chan(k);
                  t1 = get_adc_data();
                  packet0[packet_index + 2*k] = make8(t1,1);         //MSByte of data
                  packet0[packet_index + 1 + 2*k] = make8(t1,0);      //LSByte of data
                  data_collected = data_collected + 2*active_channels;
               }
               packet_index = packet_index + active_channels*2;               // the 2 multiplier is due to 16 bit or 2 bytes of data
            }

            if (packet_index + active_channels*2 > sizeof(packet0)) {
               ptr = packet_num*packet_index;
               writep_ext_eeprom(ptr, packet0, sizeof(packet0));
               packet_num++;
               packet_index = 0;
            }
         }
         else end_flag = 1;
      }

//bit banging to an external ADC
int16 get_adc_data() {
   int16 temp_val, tmp1;
   int c;

   printf("Getting Data\n\r");
   temp_val = 0b0000000000000000;

   output_high(MUX_EN);                                    // set MUX enable bit to push through mux channel
   
   // set conversion bit low to start data collection
   output_low(ADC_CONV);

   // cycle through four clock cycles to get rid of the first 4 zeros
   for (c = 0; c <= 3; c++) {
      output_high(ADC_SCK);
      output_low(ADC_SCK);
   }

   //### look at breaking this out... speed up the process significantly
   // go through 16 bits of data
   for(c = 0; c <= 15; c++){
      output_high(ADC_SCK);
      if (input(ADC_DIN)) tmp1 = 0b0000000000000001;  // \
      else tmp1 = 0b0000000000000000;               // /
      temp_val = (temp_val|(tmp1<<(15-c)));         // instruction time decreases with more shifts
      //nine clock cycles before here
      output_low(ADC_SCK);
   }

   output_high(ADC_CONV);                                    // shut down convert bit, 20 bits should have been read: 4 zeroes and 16 bits of data.
   output_low(MUX_EN);                                       // disable MUX enable

   printf("data = %lu\n\r", temp_val);

   return temp_val;
} // end get adc data


Calling the above function in the main loop with t1 = get_adc_data(); causes the " A numeric expression must appear here ". I was able to call this function before I implemented the return, so I'm sure that's the problem but I don't know how to fix it.

Thanks for the help.

Erik
_________________
Cor. 's a rough world 'innit?
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Thu Jan 21, 2010 3:33 am     Reply with quote

Which line is it complaining about ?
Where is the code that calls get_adc_data ?
Is the function defined after main or before ?
Where is the prototype ?

I suspect you modified the function header to add a return value but did not change the function prototype!
Guest








PostPosted: Thu Jan 21, 2010 7:57 am     Reply with quote

You're absolutely correct. I had, in fact, changed the header to include the returned int16... but at the same time I removed a passed variable to the function which I didn't change the function prototype to reflect! Classic too-tired too-late...

Thanks!
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