Hi Raphael, >>> rnei...@web.de 25.1.2009 0:02 >>> >Hi, > >> it seems that when I define larger variable something still goes >> wrong. > >How? What? Why? Where? Huh?!? > >> char largetestvar [100]; >> >> will cause the program to crash. > >Which program? What's crash supposed to mean: how do you observe that?
I seem to have violated all the rules of postin a meaning full question ! Sorry! I have a program, not huge, but also not trivial (half a dozen files and about 1000 lines of code). I'm mentioning that as a way of excuse for not willing (in the first instance) prune it down and realy see what is the problem. Anyway, the program works, it is runs three stepper motors very nicely. But when I started to add some functionality and increased the size of my USART communication buffer, it crashes. I sometimes see the printfed "Hello" from the program indicating that it starts, but the PIC dies. >> Changing that to: >> char at 0x300 largetestvar [100]; >> >> Removes the crash but the array does not seem to behave correctly >> (have not investigated this in detail). >> >> I'm using the standard linker script. >> >> I've tried to apply various changes to the linker script that I've >> googled up but have not been able get this to work. > >Well, what are you trying to do? Without some (compiling and failing >subset of your) source code and without compiler flags, linker flags, >compiler and gputils versions I cannot help you at all. Like I said, I'm just adding functionality and need some larger buffers, but when I add them the compiles fine but it crashes. > >> Can someone explain how the linker should be configured to allow more >> memory for variables. > >Why would you want this? The default linker script (should) declare >all availble memory banks (256 bytes each)---there is nothing you can >do to increase the available memory just by editing the linker script. > Good, glad to hear that, some web sites, see for example: http://bas.woodpecker.gotdns.org/pic.php suggest that to use all available memory tinkering the linker script is necessary. >You can edit the linker script, combining two or more successive banks >into one in order to become able to have a large array stored there >(> 256 bytes). If you do not have such an array, any regular multi-byte >variable (which is assumed to be completely in one bank by the compiler) >will be accessed incorrectly if it crosses 256-byte bank boundaries: >There will be BANKSELs missing or just issued to the wrong bank! >Editing the linker script in this way is STRONGLY DISCOURAGED! > >Please post more information about the problem, expected behaviour, >observed behaviour, error messages/warnings from compiler and/or >linker, .map file (sdcc -Wl,-m when linking or gplink -m), and >source code. > Like I said I the program is too large to post here so I guess I need to try to pin point my problems (in which case I think I may find the answer my self,most likely!). My Makefile is pretty simple: SRCS = cmdQueue.c cmdInterp.c usartirq.c stepper.c main.c LIBS = libc18f.lib libio18f4550.lib libm18f.lib libsdcc.lib SDCC = /usr/local/bin/sdcc SDCCFLAGS = "-Wl,-m,-s 18f4550.lkr" -mpic16 -p18f4550 --disable-warning 85 --std-sdcc99 OBJDIR = ../obj $(OBJDIR)/%.o: %.c $$(@D)/.f $(SDCC) -c $(SDCCFLAGS) $< -o $@ # Link the compiled files and libraries $(OBJDIR)/$(TARGET): $(addprefix $(OBJDIR)/, $(SRCS:.c=.o)) $(SDCC) $(SDCCFLAGS) -o $(OBJDIR)/$(TARGET) $(addprefix $(OBJDIR)/, $(SRCS:.c=.o)) $(LIBS) And if I do not tinker with linker script I get no error messages, just the mysterious crash.if I increase markedly the size of any of the arrays in my program. For instance I have a ring buffer for USART, it works if the array is 10 bytes but crashes if I make it 80 bytes. If I relocate the variable with eg " at 0x300" directive then the program does not crash but the characters from USART come through as 0. If I add a single 100 byte array, that I do not use for anything, the program crashes. >Regards, >Raphael br Kusti ------------------------------------------------------------------------------ This SF.net email is sponsored by: SourcForge Community SourceForge wants to tell your story. http://p.sf.net/sfu/sf-spreadtheword _______________________________________________ Sdcc-user mailing list Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user