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.
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.
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 ?
EXTRAM = 0;
AO = 0;
void putchar(char c)
xdata unsigned int plyf;
unsigned int q;
printf("Plyf is now : %05u",plyf);
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.
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.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.