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

Compile error....#reserve causes "constant out of range

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



Joined: 31 Jan 2014
Posts: 2
Location: Newark, CA USA

View user's profile Send private message Visit poster's website

Compile error....#reserve causes "constant out of range
PostPosted: Mon Feb 03, 2014 2:56 pm     Reply with quote

Hi all,

I've inherited some legacy code inside a medical product running on a Microchip 16F819 PIC. The code compiles fine in the "release" build config, but fails with an error message in the "debug" configuration. The compile error is "constant out of range". Below I've shown a snipet from the offending header file, and 1 thing I've tried to fix the error (unsuccessfully).

Thanks for any advice you can offer,

Erik
================================


Compiler error message
======================
Executing: "C:\Program Files (x86)\PICC\Ccsc.exe" +FM "opmod.c" #__DEBUG=1 +ICD +LN +T +A +M -Z +Y=9 +EA #__16F819=TRUE


*** Error 103 "C:\Users\ewilmot\16F819.h" Line 189(9,15): Constant out of the valid range 068 is reserved by the ICD



Source Code of Header file
==========================

#ifndef ALREADY_INCLUDED_16F819_H
#define ALREADY_INCLUDED_16F819_H

//////// Standard Header file for the PIC16F819 device ////////////////
#device PIC16F819 *=16 // *=16 - use 16 bit pointers (option of 5, 8 or 16)
//#device ICD=TRUE
#reserve 0xA0:0xDF // reserved for 1st half of EEPROM mirror
#reserve 0x120:0x15F // reserved for 2nd half
#reserve 0x65:0x68 // reserved for debugger...causes later error no matter what I set endpoint to...69, 70, 7F

long CCP_1; ///////////////////////////////// ERROR...068 reserved by ICD....68 changes to 69, 70, 7F if "reserve" endpoint changes
#byte CCP_1 = 0x15
#byte CCP_1_LOW = 0x15
#byte CCP_1_HIGH = 0x16

#endif ALREADY_INCLUDED_16F819_H


Other Thing I've tried
======================
I have commented out the "long CCP_1;" variable declaration, but then the same error message appears on a different line
when I hit the first line of the next header file I'm including because that line says.... #ifndef ALREADY_INCLUDED_NEXT_HEADER_H...
which is when the preprocessor tries to allocate the next variable in memory (and incorrectly uses address 068 instead of 069)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Feb 03, 2014 3:19 pm     Reply with quote

The ICD2 help topic in MPLAB lists these RAM locations:
Quote:

Reserved for debugger with 16F819:
0x2F4-0x2FF
0x065-0x070
0x0E5-0x0F0
0x165-0x170
0x1E5-0x1F0

You don't need a #reserve statement for the debugger locations.
The compiler knows about these and will not put variables there when
you have the Build mode set to Debug.

You can easily see this. Take this little program here and compile it
in Release mode. (There is a drop-down box at the top of MPLAB to
select Release or Debug). Then look at the .SYM file. Note that
variables are assigned to the 0x065-0x070 range. Then select Debug
and re-compile. Look at the .SYM file again. The compiler has now
moved variables out of the reserved range. It's all automatic.
Code:

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

int16 a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
int16 a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1,n1,o1,p1,q1,r1,s1,t1,u1,v1,w1,x1,y1,z1;


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

while(1);
}
Erik_Wilmot



Joined: 31 Jan 2014
Posts: 2
Location: Newark, CA USA

View user's profile Send private message Visit poster's website

PostPosted: Mon Feb 03, 2014 3:31 pm     Reply with quote

Awesome...thanks for the quick reply.

You fixed my problem by removing the offending #reserve statement.

You have just saved many lives (perhaps even your own) by enabling us to continue our design of life-saving medical equipment.

Erik
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