Hi,

I'm using sdcc with an pic18f2550 (with varying success), maybe I can provide 
some help (Not for win95 or USART, I don't use them).


On Tuesday 09 January 2007 14:26, Gyorgy Horvath wrote:

> 3. /sdcc/lib/src/pic16/startup
>    Since startup code does not reflect to linker script
>
>    CODEPAGE   NAME=vectors    START=0x800          END=0x829
> PROTECTED
>    CODEPAGE   NAME=page       START=0x82A          END=0x7FFF
>
>    or --ivt-loc=0x800 either we had to do something...
>
>    When I am using BRAND  USB boot-loader, I have to
>    prep the following as a workaround:
>
>    /**/
>    /* - Special remapping of vectors to 800 - tweaking crt0 */
>    /*   for AN956 USB boot loader                           */
>    /**/
>    #pragma code _reset 0x000800
>    void _reset( void ) __naked
>    {
>        __asm
>        EXTERN __startup
>        goto __startup
>        __endasm;
>    }
>    #pragma code _high_ISR  0x000808
>    void _high_ISR( void ) __naked
>    {
>        __asm
>        retfie
>        __endasm;
>    }
>    #pragma code _low_ISR  0x000818
>    void _low_ISR( void ) __naked
>    {
>        __asm
>        retfie
>        __endasm;
>    }
>
>    It seems quite ugly.. Do you have better solution?

Well, one solution would be using a custom initialization, here's how I did 
it:
Compiling with --ivt-loc=0x800 
Linking with -Wl,-s,bootloader.lkr --use-crt=bootloader_crt0i.rel

bootloader.lkr:
CODEPAGE   NAME=boot       START=0x0            END=0x7FF          PROTECTED
CODEPAGE   NAME=vectors    START=0x800          END=0x829          PROTECTED
CODEPAGE   NAME=page       START=0x82A          END=0x7FFF
...

bootloader_crt0i.c is just a copy of the original crt0i.c file, it only needs 
to be compiled with the --ivt-loc switch.

ISRs etc are defined in main.c just as they would be without a bootloader:


DEF_INTHIGH(high_isr)
  DEF_HANDLER(SIG_TMR3, timer3_handler)
END_DEF
SIGHANDLER(timer3_handler) {
...
}



DEF_INTLOW(low_isr)
  DEF_HANDLER(SIG_TMR0, timer0_handler)
END_DEF

SIGHANDLER(timer0_handler) {
...
}

and so on.

While the interrupts basically work, their entry code still seems to have some 
issues. From time to time the ISRs seem to scramble the results of the 
Calculations they interrupt.
I'm not sure yet if its a problem with all the array accesses I'm using (they 
seem to fail fairly often), or with the high ISR interrupting the low ISR, 
scrambling the data the low isr saved.

(last tried with Version #4497 (Dec  2 2006))


Greetings,
/Ernst

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to