Hi,

  Thank you very much. This really helped a lot :)

    -Mika

> Hi Mika,
>
>>   Managed to compile a sample code below with sdcc, but the xdata
>> definition can not be found from header files (except from testfwk.h).
>
> The PIC architectures do not offer anything like external data memory;
> so either just
> #define xdata __data
> or replace it (as you did).
>
>> What would be the correct way to introduce the heap ?
>> data char heap[256];
>
> That looks pretty good, __data instead of data is safer, though.
>
>> // data char heap[512]; This gives linker error, do not know why
>
> The reason for the linker error is that the PIC organizes its memory in
> banks of 256 bytes each. You cannot declare structures/arrays larger
> than that unless you know what you are doing and modify the .lkr script
> (combine two adjacent banks (END address of first = START address of
> second - 1), i.e., turn
>
> DATABANK   NAME=gpr1       START=0x100          END=0x1FF
> DATABANK   NAME=gpr2       START=0x200          END=0x2FF
>
> into
>
> DATABANK   NAME=gpr1       START=0x100          END=0x2FF
>
> Save the modified 18f4550.lkr in your project directory and add
> -Wl,-s,18f4550.lkr to sdcc's command line (or -s 18f4550.lkr to gplink's
> command line, depending on your build system/style) to use it.
>
> Make sure, though, that you *always* statically allocate the heap of at
> least 256 bytes if you do this, otherwise a random multi-byte entity (an
> int, a struct, ...) might be placed across the bank boundaries, which
> breaks compiler assumptions about BANKSEL placement and might cause
> accesses to the entity to fail (read/write in the wrong bank, good luck
> hunting such bugs!).
>
> Also, make sure to add
> #pragma stack 0x300 0x100
> to your main() file to move the stack from its standard location
> (0x200-0x2FF) to 0x300-0x3FF. You might also reduce the stack size
> (0x100 => 256 bytes, 0x80 => 128 bytes *might* suffice, you could try).
>
> Note that using a 512 byte heap and a 256 byte stack leaves 'just' 160
> byte of the 4550 available for other stuff.
>
> Hope that helped,
> Raphael
>
> -------------------------------------------------------------------------
> 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