Using XRAM on the P89C66x

RaceMouse
2004-11-04
2013-03-12
  • RaceMouse

    RaceMouse - 2004-11-04

    Hi,

    I have a problem making my code work. It is very simple  - prints out a vaiable via printf -> lcd display connected to P2. It works fine using the command line
    "sdcc -c dispport.c && sdcc -o main.hex main.c dispport.rel".

    No errors and the display does it job. Moving the variable to XRAM using "xdata unsigned char plyf;" and the comman line
    "sdcc -c --model-large dispport.c && sdcc -o main.hex --model-large main.c dispport.rel"
    compiles fine and with no errors. After uploading it to the MCU nothing happens. It seems as if the MCU is not raecing main().

    WDT is disabled by default, so I guess that is not an issue.

    Anything that can point me in the right direction will be greatly appreciated as I would like to use the SDCC on a more permanent basis.

    Thanks in advance for your help.

    /RaceMouse

     
    • Maarten Brock

      Maarten Brock - 2004-11-08

      It's all there in the datasheet. I presume you don't have an external memory chip connected and want to use internal ERAM for xdata. To make that work you need to set the bit EXTRAM to 0 in sfr AUXR. The best place to do that is in a function called char _sdcc_external_startup(void) which will be automatically called during initialization. You must return 0 from it if you want normal initialization of variables to take place.

      Greets,
      Maarten

       
      • RaceMouse

        RaceMouse - 2004-11-08

        Hi again, First: Thanks for taking your time to help me out here :-)

        The program below is the one I'm tring to make work. The variable 'plyf' is put in xdata and under a normal compile+linking it is therefore unreachable outside the idata area. This _should_ be fixed by using the following command line "sdcc -c --model-large --xram-size 1792 dispport.c && sdcc -o main.hex --model-large --xram-size 1792 main.c dispport.rel", right ?

        I'm sorry but the above tip didn't help a bit. Is there a syntax error in the code below or is the command line faulty ?

        #include <stdio.h>
        #include <reg66x.h>
        #include "dispport.h"

        char _sdcc_external_startup(void)
        {
            EXTRAM = 0;
            AO = 0;
            return (0);
        }

        void putchar(char c)
        {
            d_putchar(c);
        }

        xdata unsigned int plyf;

        main()
        {
            unsigned int q;
            init_display();
            cursor(1,1);
            cld();
            printf("PLYF!");
            while(1)
            {
                cursor(2,1);
                for(q=0;q<65535;q++);
                plyf++;
                printf("Plyf is now : %05u",plyf);
            }
        }

         
    • Maarten Brock

      Maarten Brock - 2004-11-09

      Using --model-large doesn't fix that the variable is unreachable outside the idata area. First it's not in the idata area and never will be when declared with xdata. Second your program knows it's in xdata (you just specified that) so you don't need to tell that on the commandline. Third using xdata on the variable overrides the model behaviour, not the other way around. Using --model-large tells the compiler to put all not-explicitly declared variables in xdata (like your "q").

      I guess your program doesn't compile as EXTRAM is not bit-addressable neither is AO. You must set AUXR to 0.

      Finally,what version of SDCC do you use? There were problems with printf that have been fixed only this week.

       
      • RaceMouse

        RaceMouse - 2004-11-09

        Thanks a lot. That did the trick. Being used to all bit addressable registers (the PICs) I overlooked the bit/byte addressable detail. O'well...

        Anyways. Thanks a lot for the help. It is really appreciated :-)

         

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks