Dennis,

Initially you had --xram-loc=0x4000, but the FX2 has 
only 16kB RAM so there is nothing at 0x4000 unless you 
have external RAM connected. Without any --xram-loc SDCC 
puts xdata at 0x0000 but unless you have external ROM 
and EA=1 this memory is shared with code memory. So any 
write to xdata 0x0000 and up will overwrite the reset- 
and interrupt vectors and the rest of your program!

During initialization SDCC needs something like P2 on 
the original 8051 to output the high byte of the 
address. For the FX2 this is MPAGE (0x92) and you need 
to tell SDCC about it through defining _XPAGE.  An 
alternative is to reassemble crtxinit.asm for dual data 
pointer use as the FX2 supports that as well.

So if you only have internal memory, you best use --
code-size=0x3000 to limit the generated code size and --
xram-loc=0x3000 and --xram-size=0x1000 to make sure 
xdata does not overlap with code memory.

Maarten

> Dennis Muhlestein wrote:
> > Dennis Muhlestein wrote:
> >> I have a little test program I've been playing with to test different 
> >> variable sizes and locations.  I came across a weird situation and 
> >> I'm hoping someone can help me explain it.
> > I've traced this problem down to a smaller issue.
> >
> > It seems the declarations and initialization of the xdata are what is 
> > breaking my firmware.  The following is broken:
> >> xdata BYTE buf[100];
> >> xdata WORD count=0;
> >
> I think this problem has to do with the _XPAGE sfr.
> 
> Defining _XPAGE for sfr at 0x92 seems to fix the global initialization 
> problem.
> 
> I'm not entirely sure the problem is gone, but it at least fixes my 
> simple test case.
> 
> For my program to work, I still have to use --xram-loc of somewhere 
> around 896 to 1024 bytes (0x0400 works)
> 
> Can anyone shed some light as to why the default xram location doesn't work?
> (cypress fx2lp)
> 
> -Dennis
> 
> 
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Sdcc-user mailing list
> Sdcc-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/sdcc-user
> 



-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to