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

Error#27 Expression must evaluate to a constant

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



Joined: 03 Mar 2015
Posts: 5

View user's profile Send private message

Error#27 Expression must evaluate to a constant
PostPosted: Wed Mar 04, 2015 12:56 am     Reply with quote

Hi,

Can anybody help me out, to resolve error "Error#27 Expression must evaluate to a constant" while compiling my project in MPLABX IDE v.2.26 with CCS compiler(Version 1.46). Most of the files are having similar problem, due to this I am unable to build my project.

Sample code:
Code:

unsigned char FRAM_INIT_DATA[16] =
{   0,
   0x21, 0x49, 0x6E, 0x74, 0x65, 0x6C, 0x6C,   // "!Intell"
   0x69, 0x44, 0x61, 0x74, 0x61, 0x2E, 0x21,   // "iData.!"
   0
};

Here I am getting the error at first line itself.

Thanks in advance.
Ttelmah



Joined: 11 Mar 2010
Posts: 19519

View user's profile Send private message

PostPosted: Wed Mar 04, 2015 2:30 am     Reply with quote

Start at the beginning. Your compiler is not V1.46. V1 compilers data back something like 20 years, and would not work in any way with MPLABX.
Compiler version is either available through 'help', 'about', or is at the top of the .lst file.

However then your problem is not in the code posted.

CCS has a somewhat annoying habit, when you have certain types of syntax error, of 'keeping going', accepting later code, until suddenly the cumulative error, gets bad enough, that it cannot proceed any further. It then flags the error as happening at this point, when the real syntax error can be several (even hundreds!) of lines before.

You need to look at the lines in front of what you have posted. It'll be something silly like a missing closing brace, semi-colon etc., which means that the next few lines are being treated as if they are still part of an earlier statement....
muralijelije



Joined: 03 Mar 2015
Posts: 5

View user's profile Send private message

PostPosted: Wed Mar 04, 2015 3:59 am     Reply with quote

Code:
#ifndef mkm14_fram_H
#define mkm14_fram_H

/*////////////////////////////////////////////////////////////////////////////
////   Library for a Ramtron 25C160                            ////
////                                                   ////
////   init_ext_fram();    Call before the other functions are used   ////
////                                                   ////
////   write_fram_byte(a, d);  Write the byte d to the start_addr a   ////
////                                                   ////
////   d = read_fram_byte(a);   Read the byte d from the start_addr a   ////
////                                                   ////
////   b = read_fram_status();  Returns the fram status bits          ////
////                                                   ////
////                                                   ////
////               Pin Layout                               ////
////   -------------------------------------------------            ////
////   |    __                               |            ////
////   | 1: CS      FRAM_CS      | 8: VCC   +5V         |            ////
////   |                  |    ____             |            ////
////   | 2: SO      FRAM_SO      | 7: HOLD   +5V          |            ////
////   |    __             |                  |            ////
////   | 3: WP      +5V       | 6: SCK   FRAM_CLK   |            ////
////   |                  |                  |            ////
////   | 4: VSS     GND       | 5: SI      FRAM_SI      |            ////
////   -------------------------------------------------            ////
////                                                   ////
////////////////////////////////////////////////////////////////////////////*/


#define FRAM_SIZE 2048      // FM25C160 16kbit

// opcodes
#define FM_WREN      0x06   // Set write enable latch
#define FM_WRDI      0x04   // Explicit clear write enable latch
#define FM_RDSR      0x05   // Read status register
#define FM_WRSR      0x01   // Write status register
#define FM_READ      0x03   // Read memory data
#define FM_WRITE   0x02   // Write memory data

// Write protect mechanism using FRAM_WP relies on setting Block Protect bits first
//       bit     3 2
//   BP1, BP0   = 0,0      // unprotected
//   BP1, BP0   = 0,1      // protect 0x600 to 0x7FF (quarter)
//   BP1, BP0   = 1,0      // protect 0x400 to 0x7FF (half - Default)
//   BP1, BP0   = 1,1      // protect 0x000 to 0x7FF (all)

#define   WPEN_SET   0x80   // allows FRAM_WP to be effective
#define   BP0_SET      0x04
#define   BP1_SET      0x08

#define PROTECT_ECB   0x88   // WPEN_SET | BP1_SET (Half is protected)
#define   PROTECT_ALL   0x8C   // If saving calibration stuff in FRAM

#define   FRAM_ECB_INIT_BGN      0x0400   // start of data to indicate not first turn-on
#define   FRAM_ECTRL_SIZE         0x03B0   // 0x400->07AF
#define FRAM_INIT_DATA_SIZE      16      // allowed length of initialisation data
#define   FRAM_ECB_INIT_CHKSM      0x04BB

This was the code exist before below one.(In .h file)

This is the code sample from .c file where I am getting the same error in .c file

#if defined(__PCM__)
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#elif defined(__PCB__)
#include <16C56.h>
#fuses HS,NOWDT,NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A2)
#elif defined(__PCH__)
#include <18F458.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#elif defined(__PCD__)
#include <30F2010.h>
#fuses HS, NOWDT, NOPROTECT
#use delay(clock=20000000)
#use rs232(baud=9600, UART1A)
#endif


//#include"prototypes.h" // ksrinivas
#include<stddef.h>
#include"mkm14_cnvrt.h"  // ksrinivas
#include"mkm14_fram.h"  // ksrinivas
#include"mkm14_crus.h"  // ksrinivas
#include"mkm14_eprm.h"  // ksrinivas
//#include<stddef.h>         // for offsetof()

void energy_manager(void) -- here is the line whare I am getting the similar issue in .c file. Though there is no error it is reporting.
I have gone through the code as per your suggestion. But no luck.
Code:

void energy_manager(void)
{
   int8   i; //
   static int8 energy_task_cntr;
        energy_task_cntr= NEW_READING;
   int16   chksum;
   int16   fm_addr;

// ALL functions take approx 35mS

   
}

Can you please help me out
Ttelmah



Joined: 11 Mar 2010
Posts: 19519

View user's profile Send private message

PostPosted: Wed Mar 04, 2015 4:55 am     Reply with quote

1) Learn to debug.
Start with just the simplest program. Get it to compile and work _first_.
I suspect you may have as one problem, MPLAB configured incorrectly, so it is trying to load the separate files.
2) Once you have a simple program working, add things one at a time. You should be able to add each individual include. If after the second a fault appears, then you have narrowed down where to look.
3) Once you have located where the problem appears, as a small compilable program, then you can post this. It is impossible to debug 'bits', and you are wasting our time, and yours by posting these.
4) You still have not told us the compiler version.
muralijelije



Joined: 03 Mar 2015
Posts: 5

View user's profile Send private message

PostPosted: Wed Mar 04, 2015 5:27 am     Reply with quote

Thanks a lot for keeping me right direction.

I will try these steps first.


Following are the CCS compiler version details.

IDE 5.06
PCB,PCM,PCH and PCD vesrions are 5.043.
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