Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Im getting the following error message for C Using PIC

Status
Not open for further replies.

faomari

New Member
The error is the following
"Can't find 0x58 words for psect rbss_0 in segment BANK0 (error)"
Think its something to do with writing too many strings with too many characters so there isnt enough space, if so is there a way to clear a string after using it. Im thinking of making the string = "" but dont think thats very proffesional, not that im a pro at this or anything.

Thanks
 
tell us what compiler you are using. and show us some of your codes/routines for us to be able to comment.
 
Ok, im using the following compiler. "HI-TECH PICC COMPILER (Microchip PIC) V8.02 PL1". I had intitially character of the following form:-
char INTRO[] ="fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";

What i was doing before in which it was giving me the error "Can't find 0x58 words for psect rbss_0 in segment BANK0 (error)". Is that when i make that Char INTRO[] a bit bigger or intialise another char variable of a form like this for example
char INTRO1[] = "EE";

it gives that error, iv been reading about and found that you could do RUN-TIME Storage allocaion in which you can allocate and free memory. Is this possible when using a PIC. I have somehting like this in my funciton but the compiler is giving me error.

void Start()
{


char* INTRO;
INTRO = malloc(sizeof(char));
setUpAsynchUSART();

while(1)
{
while(AsUSARTgetByte() != ' ');
strcpy(INTRO,"Hello world\n");
AsUSARTsendBytes(INTRO);
free(INTRO);

/*strcpy(Verse,"dsffdsf");*/
/*AsUSARTsendBytes(Verse);*/
while(AsUSARTgetByte() == 0);
while(1)
{
AsUSARTsendByte('a');
AsUSARTsendByte('b');
AsUSARTsendByte('c');
AsUSARTsendByte('\n');
AsUSARTsendByte('\r');
delay_ms(100);
}



}

}

The error file is giving me this message:-

: : undefined symbols: (error)
: : _free (HEAD1.OBJ) (error)
: : _malloc (HEAD1.OBJ) (error)

P.S i did include this on top.
#include <stdlib.h>
 
The error file is giving me this message:-

: : undefined symbols: (error)
: : _free (HEAD1.OBJ) (error)
: : _malloc (HEAD1.OBJ) (error)
it looks like there is a compiler problem or some settings in looking for the free and malloc functions.

char* INTRO;
INTRO = malloc(sizeof(char));

strcpy(INTRO,"Hello world\n");
the syntax is correct but this will only allocate one byte in the memory allocated by the ponter INTRO. you can't put more than one character in it, and putting string in it will cause you a run-time error.

you can do manual adjustment. by doing something like this.

Code:
#define MY_CHAR_POINTER_BYTE_SIZE    20

char *INTRO=NULL; 
// allocate 20 bytes
INTRO = malloc( (sizeof(char)) * MY_CHAR_POINTER_BYTE_SIZE );

// this is a must, check if memory allocation is succesful
if(INTRO==NULL)
// dynamic memory allocation failed

btw, how big is the RAM of the PIC you are using and what PIC is it?
 
thanks, still getting that error though, in which it cant find the malloc function, ill let you know if i can figure it out, im using pic16f866.
 
Big computer people are really tiresome when they come to swim in the microcontroller pond and bemoan the loss of their favoite resources. Go back up to the big machines where you belong.
 
papabravo, how about you chill out a bit, and not be so uptight. Im trying to learn some new things here, so spare me your nerdy comments.
 
IIRc the error you state comes from either not having enough RAM available, or not having enough RAM to put a variable structure in one memory bank.

Memory is most often automatically divvied up as an Overlay. This only works when you declare the variables inside a code block (a "{...}"). The compiler looks for which code blocks cannot be active at the same time and may reuse the same memory for more than one block's variables.

char INTRO1[] = "EE";
May be unwise. How big a space do you want to reserve for "INTRO1[]"?
Actually I don't know how much space the compiler interprets this as, I think just 3. If you later assigned more- like INTRO1="This is my String"; then the code will assign to RAM that wasn't reserved for it and may contain other variables. This is typically very effective.

The is no way for the core to perform memory management. You can under some instances manually manage memory reuse, for example if you globally declare a 256 byte array you could place variables inside the array's space whenever and whereever you want. Of course it is easy to make a mistake and use a byte for a new variable when the old one in that spot is still needed, there is no way to automatically detect this at compile, link, or run time.
 
Actrually not sure, i havent come across any code in which that certain PIC uses functions such as malloc.
 
Last edited:
İ think your PIC's RAM doesnt enough for your string.Save your string in ROM and......

for example..;

char INTRO[] ="ffffffffffffffffffffffffffffffffffffffffffffffff fffffffffffffffffffffffffff";
is very big for your pic..

char INTRO[] ="fffffff";
This string didnt give any error message...

I think these can solve your problem...

I'm sorry for my poor english..excuse me..
 
Use in this form ;
char INTRO[]={f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f};
or
char INTRO[]={"ffffffffffffffffffffffffffffffff"};
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top