DS80C400 and memory space with the SDCC compiler

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
I am using a version of the TINIm400 and the TINIs400 reference design with
an FPGA connected to CE3 and CE4.

I wish to access the registers I  have placed in the FPGA but am wondering
how to do it.  I assume by default the FPGA is effectively at 0x60 0000 (for
CE3) but how do I place a variable at this address so I can access with a C
instruction.

Apologies if it's very obvious.



Re: DS80C400 and memory space with the SDCC compiler
Fred said
Quoted text here. Click to load it

Well, you could just set up a suitable structure pointer to that
location along the lines of this:

typedef struct
   {
   short int     register_for_this;
   short int     register_for_that;
   unsigned char register_for_8_bit_stuff;
   }  FPGA_REGS;


void my_fpga_reg_routine( void )
   {
   FPGA_REGS regs;

   regs = (FPGA_REGS *)(0x600000);
        
   regs->register_for_this        = 0x1234;
   regs->register_for_that        = 0x5678;
   regs->register_for_8_bit_stuff = 0x9A;
   }




Casey

Re: DS80C400 and memory space with the SDCC compiler
Casey said
Quoted text here. Click to load it

(correction)

     FPGA_REGS *regs;

Quoted text here. Click to load it

Well, that should work a little better ....



 
Casey

Re: DS80C400 and memory space with the SDCC compiler
Casey

Many thanks for your illustration.  I have written the following but I get
an error:

typedef struct
   {
   short int     register_for_this;
   short int     register_for_that;
   unsigned char sdram_reset_reg;
   }  FPGA_REGS;

   FPGA_REGS *regs;

void main()
{

   regs = (FPGA_REGS *)(0x600000);

   regs->register_for_this        = 0x1234;
   regs->register_for_that        = 0x5678;
   regs->sdram_reset_reg          = 0x9A;

}

on the command line:
sdcc -c -mds400 --model-flat24 --stack-10bit --no-xinit-opt main.c

I get this error:
main.c:13 error: illegal cast of LITERAL value to 'generic' pointer
from type 'literal-long-int'
to type 'struct __00010000 generic* '

which essentially doesn't like:
   regs = (FPGA_REGS *)(0x600000);

Although I have written a fair amount of code I am not that knowledgable of
how to assign a varaible to a location and compilers sometimes treat things
differently.  This request is perhaps unusual for a 8051 processor which has
a 24 bit linear addressing mode.




Re: DS80C400 and memory space with the SDCC compiler
Fred said
Quoted text here. Click to load it

The 8051 family addressing can be a pain ... you probably need to
qualify the type of pointer being created.  Your FPGA is probably
in xdata memory space.

I've never used the SDCC compiler, but you probably need to do
something like this to explain that you're creating a pointer to
xdata (far) memory:

void main()
   {
   xdata FPGA_REGS *regs;
   regs = (xdata FPGA_REGS *)(0x600000);

   regs->register_for_this = 0x1234;
   regs->register_for_that = 0x5678;
   regs->sdram_reset_reg   = 0x9A;
   }


If you don't want your pointer as a stack variable for the function,
you could move it outside the function and put the pointer itself in
xdata space:

xdata FPGA_REGS * xdata regs;


I did a quick lookup of the SDCC storage classes at:

http://tinyurl.com/6tfaa


If you haven't already, you might take a look at this app note as well:

http://www.maxim-ic.com/appnotes.cfm/appnote_number/3346





Casey

Re: DS80C400 and memory space with the SDCC compiler
Quoted text here. Click to load it
<snip>
Quoted text here. Click to load it

Try this:
xdata at 0x60000 volatile FPGA_REGS * regs;



Re: DS80C400 and memory space with the SDCC compiler
Quoted text here. Click to load it

After looking at it, that might not work.  You may have to specify the
size of the regs item.  Like this:
xdata at 0x600000 volatile UC regs[put size here];


Re: DS80C400 and memory space with the SDCC compiler
Many thanks for the help.  This is what I used in the end

xdata at 0x600000 unsigned char sdram_reset_reg;

which work such that I can read and write at this "location" in the FPGA
using CS3.



Site Timeline