View previous topic :: View next topic |
Author |
Message |
asmallri
Joined: 12 Aug 2004 Posts: 1636 Location: Perth, Australia
|
Bug or misunderstanding of #locate? |
Posted: Mon Oct 02, 2006 1:25 am |
|
|
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
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
|
|
Posted: Mon Oct 02, 2006 1:43 am |
|
|
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: 1636 Location: Perth, Australia
|
|
|
|