I'm using EZ-USB FX2LP (CY7C68013A) and sdcc compiler. And my problem is that i cann't load char xdata var[128] in controller. I guess that is some memory problem. Here is my makefile:
INCLUDES = -I../include
CC = sdcc -mmcs51 -c
BASENAME = main relay adc mux exch gpif
OBJNAME = $(BASENAME:=.rel)
OUTFILE = main.ihx
CYCFX2PROG = cycfx2prog
all: run clean
run: $(BASENAME) link
$(CYCFX2PROG) prg:$(OUTFILE) run
What exactly doesn't work? Do you get errors? If so, which? You do know that xdata should have two underscores in front (__xdata)?
And where are the --code-loc, --code-size, --ram-loc, --ram-size options? Unlike the original mcs51 the FX2 uses the same memory for both code and xdata. So you must split its use or xdata writes will destroy your program.
Maarten
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I mean is when i initialize variable like this: const char xdata WaveData[128] processor stops working (WaveData[128] is global variable). But there are no errors during compiling. In datasheet mentions exactly xdata not __xdata. And if i understood correctly code memory location (--code-size) and external memory location (--xram-size) is the same (starts with 0x0000). And i didn't find --ram-loc, --ram-size options, may be you mean --xram-loc, --xram-size?
Regards, Roman.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But you missed my point that code and external memory should not overlap! Exactly because on the hardware they are the same. On an original mcs51 code memory is a separate memory from xram and both can grow to 64kB. So address 0x0000 in code has the reset vector, but 0x0000 contains a variable.
Now on the FX2 code memory and xram are one and the same. If you write to your variable at 0x0000 the reset vector is overwritten! So you must tell sdcc not to place variables in the area reserved for your code. How you divide the memory is up to you. Assuming you have 16kB in the FX2 you could choose 12kB code and 4kB xram like so:
--code-loc 0x0000
--code-size 0x3000
--xram-loc 0x3000
--xram-size 0x1000
Now your program lies in the first 12kB and your variable data in the last 4kB and the linker will complain when it runs out of memory.
It also really matters whether WaveData is const or not. If you mark it const and still place it in __xdata it will need to be initialized at startup. But if you leave out __xdata and just use const and/or __code it will be placed in code memory and is initialized at download.
Finally, xdata and __xdata have the same meaning but sdcc switched to use __xdata in the past for standard compliance. It is not allowed for a C compiler to introduce new keywords that do not start with a double underscore. However Keil still uses xdata which is why it is probably in your datasheet.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But problem still occur, may be i do something wrong. I tried to change xdata to __xdata, tried to write in link: option like this:
sdcc --code-loc 0x0000 --code-size 0x2000 --xram-loc 0x2000 --xram-size 0x2000 -o $(OUTFILE) $(OBJNAME)
but it all wasn't help me.
May be i should notice that i use 2.9.0 version of sdcc, newer version don't work with Cypress source files.
Regards, Roman
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm using EZ-USB FX2LP (CY7C68013A) and sdcc compiler. And my problem is that i cann't load char xdata var[128] in controller. I guess that is some memory problem. Here is my makefile:
INCLUDES = -I../include
CC = sdcc -mmcs51 -c
BASENAME = main relay adc mux exch gpif
OBJNAME = $(BASENAME:=.rel)
OUTFILE = main.ihx
CYCFX2PROG = cycfx2prog
all: run clean
run: $(BASENAME) link
$(CYCFX2PROG) prg:$(OUTFILE) run
link:
sdcc -o $(OUTFILE) $(OBJNAME)
clean:
del /f /q .asm .ihx .lnk .lst .map .mem .rel .rst *.sym
$(BASENAME):
$(CC) $(INCLUDES) ../src/$@.c
Can you help me?
Last edit: Roman 2013-09-21
What exactly doesn't work? Do you get errors? If so, which? You do know that xdata should have two underscores in front (__xdata)?
And where are the --code-loc, --code-size, --ram-loc, --ram-size options? Unlike the original mcs51 the FX2 uses the same memory for both code and xdata. So you must split its use or xdata writes will destroy your program.
Maarten
Maarten, thanks for reply.
I mean is when i initialize variable like this: const char xdata WaveData[128] processor stops working (WaveData[128] is global variable). But there are no errors during compiling. In datasheet mentions exactly xdata not __xdata. And if i understood correctly code memory location (--code-size) and external memory location (--xram-size) is the same (starts with 0x0000). And i didn't find --ram-loc, --ram-size options, may be you mean --xram-loc, --xram-size?
Regards, Roman.
Sorry, yes I meant --xram-loc and --xram-size.
But you missed my point that code and external memory should not overlap! Exactly because on the hardware they are the same. On an original mcs51 code memory is a separate memory from xram and both can grow to 64kB. So address 0x0000 in code has the reset vector, but 0x0000 contains a variable.
Now on the FX2 code memory and xram are one and the same. If you write to your variable at 0x0000 the reset vector is overwritten! So you must tell sdcc not to place variables in the area reserved for your code. How you divide the memory is up to you. Assuming you have 16kB in the FX2 you could choose 12kB code and 4kB xram like so:
--code-loc 0x0000
--code-size 0x3000
--xram-loc 0x3000
--xram-size 0x1000
Now your program lies in the first 12kB and your variable data in the last 4kB and the linker will complain when it runs out of memory.
It also really matters whether WaveData is const or not. If you mark it const and still place it in __xdata it will need to be initialized at startup. But if you leave out __xdata and just use const and/or __code it will be placed in code memory and is initialized at download.
Finally, xdata and __xdata have the same meaning but sdcc switched to use __xdata in the past for standard compliance. It is not allowed for a C compiler to introduce new keywords that do not start with a double underscore. However Keil still uses xdata which is why it is probably in your datasheet.
Maarten, thanks for helping
I changed my makefile to this (i have exactly 16 kB RAM):
INCLUDES = -I../include
CC = sdcc -mmcs51 --code-loc 0x0000 --code-size 0x2000 --xram-loc 0x2000 --xram-size 0x2000 -c
BASENAME = main relay adc mux exch gpif
OBJNAME = $(BASENAME:=.rel)
OUTFILE = main.ihx
CYCFX2PROG = cycfx2prog
all: run clean
run: $(BASENAME) link
$(CYCFX2PROG) prg:$(OUTFILE) run
link:
sdcc -o $(OUTFILE) $(OBJNAME)
clean:
del /f /q .asm .ihx .lnk .lst .map .mem .rel .rst *.sym
$(BASENAME):
$(CC) $(INCLUDES) ../src/$@.c
But problem still occur, may be i do something wrong. I tried to change xdata to __xdata, tried to write in link: option like this:
sdcc --code-loc 0x0000 --code-size 0x2000 --xram-loc 0x2000 --xram-size 0x2000 -o $(OUTFILE) $(OBJNAME)
but it all wasn't help me.
May be i should notice that i use 2.9.0 version of sdcc, newer version don't work with Cypress source files.
Regards, Roman
Problem solved. There was also my program errors. So, Maarten, great thanks!