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

Bug or misunderstanding of #locate?

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



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Bug or misunderstanding of #locate?
PostPosted: Mon Oct 02, 2006 1:25 am     Reply with quote

PCH Version PCH v3.243

Here is an extract of a symbol file

Code:

100-13F RxBaseSW
140-17F TxBaseSW
140-33F buffer


Note the two memory regions TxBaseSW and buffer overlap.

RxBaseSW and TxBaseSW are declared in an include file.
buffer is declared after the include file

Here are the relevant defines from the include file:
Code:
   // Define the size of the serial ring buffers
#define RxQsizeSW      64   // SW_UART Rx buffer size
#define TxQsizeSW      64   // SW_UART Tx buffer size

   // SW UART ring buffers
volatile byte   RxBaseSW[RxQsizeSW];   #locate RxBaseSW = 0x0100            // Rx buffer
volatile byte   TxBaseSW[TxQsizeSW];   #locate TxBaseSW = RxBaseSW + RxQsizeSW   // Tx buffer


Here is the declaration of buffer which is a global variable declared immediately after the include file statement

Code:
byte buffer[512];   


I expected the use of #locate would have prevented the compiler from overlaying the address space of these global variables.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Oct 02, 2006 1:43 am     Reply with quote

I was able to duplicate your problem with PCH vs. 3.249.

I was able to fix it by using a constant for the base address.
Here are the results:
Code:

RxBaseSW      00000100
TxBaseSW      00000140
buffer        00000180


I think the compiler just wants to see a constant for #locate.
I don't think it can handle anything else. Here is the modified program:
Code:

#include <18F452.h>
#fuses XT,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP
#use delay(clock=4000000) 
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

#define RxQsizeSW  64   
#define TxQsizeSW  64   
#define ARRAY_BASE  0x100

volatile byte RxBaseSW[RxQsizeSW]; 
#locate RxBaseSW = ARRAY_BASE     
volatile byte TxBaseSW[TxQsizeSW];
#locate TxBaseSW = ARRAY_BASE + RxQsizeSW   

byte buffer[512];   

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

while(1);
}
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Mon Oct 02, 2006 1:53 am     Reply with quote

Thanks.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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