Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with making an array of 256 characters in a PIC877 based unit

Status
Not open for further replies.

aviv6371

Member level 2
Joined
Jul 7, 2006
Messages
45
Helped
1
Reputation
2
Reaction score
0
Trophy points
1,286
Activity points
1,574
hello,

i m building pic877 based unit and i need to make array of 256 characaters.
when i typed the declaration:
unsigned char arr[256];

i got error message :" words for psect "rbss_0" in segment "BANK0"

when i changed the array declaration to:

unsigned char arr[66]

it worked !!

now i need 256 characters. i heard something about declaration of bank1 at the beginning. not sure .

can anybody put some light over this subject ???

any help would be appreciated.

avi.
 

Re: pic memory storage problem.....

I assume you are using Hi-Tech C?

The 16F877 has four memory banks, so declaration would look like this:

bank1 unsigned char test[XX]
bank2 unsigned char test[XX]
bank3 unsigned char test[XX]

If you do not specify the memory bank using the bankX keyword bank0 will be uesed.

Problem is that the 16F877 does not have a memorybank where you could use 256 bytes :cry:

Most memory banks are 80 or max 96 bytes in size.

Take a look at the datasheet.

best regards
 

Re: pic memory storage problem.....

hello C-Man and others,

thanx for the fast answer.
according to it if i want to erase the 256 char array i can do it by:

bank1 unsigned char test[96];
bank2 unsigned char test [96];
bank3 unsigned char test[64];

for (i=0;i<=255;i++)
test=' ';

is it legal ????


avi.
 

Re: pic memory storage problem.....

Hi

Code:
[quote]bank1 unsigned char test[96];
bank2 unsigned char test [96];
bank3 unsigned char test[64]; [/quote]


I think dupliaction of naming of variable is not allowed
 

Re: pic memory storage problem.....

the problem is that i have to proccess 256 characters that would be saved eventually in the eeprom. i need to deal with diffrent banks with diffrent amount of ram.

how can i do the job ??????

avi.
 

Re: pic ram memory .....

Here is an example how i did an interrupt controlled RS232 buffer for 256 characters using an 16F88

write to buffer

Code:
#define BUFFER_GROESSE 64

static volatile persistent byte Buffer1[BUFFER_GROESSE];
bank1 static volatile persistent byte Buffer2[BUFFER_GROESSE];
bank2 static volatile persistent byte Buffer3[BUFFER_GROESSE];
bank3 static volatile persistent byte Buffer4[BUFFER_GROESSE];

static byte zeiger_schreiben=0

if(RCIF)                                                                                                             
{                                                                                                                    
	rx_datenbyte=RCREG;                                                                                               
                                                                                                                     
	if(FERR)                                                                                                          
		rx_datenbyte=RCREG;                                    
                                                                                                                     
	receive_timer=RECEIVE_TIMEOUT;                                                                                    
                                                                                                                     
	if(!OERR)                                                                                                         
	{                                                                                                                 
		if(!(zeiger_schreiben & 128))                                                                               
		{                                                                                                           
			if(!(zeiger_schreiben & 64))                                                                             
				Buffer1[zeiger_schreiben & 0x3F]=rx_datenbyte;                           
			else                                                                                                     
				Buffer2[zeiger_schreiben & 0x3F]=rx_datenbyte;                          
		}                                                                                                           
		else                                                                                                        
		{                                                                                                           
			if(!(zeiger_schreiben & 64))                                                                             
				Buffer3[zeiger_schreiben & 0x3F]=rx_datenbyte;                          
			else                                                                                                     
				Buffer4[zeiger_schreiben & 0x3F]=rx_datenbyte;                                  
		}                                                                                                           
                                                                                                                  
		zeiger_schreiben++;                                                                                         
	}                                                                                                                 
	else                                                                                                              
	{                                                                                                                 
		CREN=FALSE;                                 
		CREN=TRUE;                                                                                                     
	}                                                                                              
}

read from buffer

Code:
static byte Zeiger_Lesen=0;

if(!(Zeiger_Lesen & 128))
{
	if(!(Zeiger_Lesen & 64))
		zeichen=Buffer1[Zeiger_Lesen & 0x3F];
	else
		zeichen=Buffer2[Zeiger_Lesen & 0x3F];
}
else
{
	if(!(Zeiger_Lesen & 64))
		zeichen=Buffer3[Zeiger_Lesen & 0x3F];
	else
		zeichen=Buffer4[Zeiger_Lesen & 0x3F];

	Zeiger_Lesen++;
}

hope you can see the idea behind it :D

best regards
 

Re: pic ram memory .....

You may not need to define such array
I think that you can use indirect addressing instead by using FSR and INDF registers.
You will just need to update the address that woill point to your RAM location.

In this case you will need to find some way to gaurd your selected RAM areas from being used by the compiler if you have more variables used in the code


Thanks
 

Re: pic ram memory .....

hi,

C-Man - i tryed but i get error message : " fixup overflow in expression (location 0xC6C (0xC66+6), size 1, value 0x1A2)"

by the way why have u declared the array as static volatile persistent and not normal unsigned char ???

Haythan - yes theres another way the name is pointers and it could be done with c
. its more efficient methode because i dont have to waste expensive ram by allocating fixed amount of array, with pointers i allocate data only when needed.
the problem is that i dont know how to do it !!!

any suggestions ????


avi.
 

Re: pic ram memory .....

aviv6371 said:
hi,

C-Man - i tryed but i get error message : " fixup overflow in expression (location 0xC6C (0xC66+6), size 1, value 0x1A2)"

by the way why have u declared the array as static volatile persistent and not normal unsigned char ???

volatile because it is changed from an interrupt function and persistant because i do not need the array initialized to 0 by the startupcode this saves a bit of codespace.

You could leave out static but i do not want the buffer to be visible to another program module when linked together.

To check your error i would have to see your code but it could be a problem with not enough memory left in bank 0 ...

best regards
 

Re: pic ram memory .....

hi C-Man ,

i have made the declaration : ( compiled with picc light )

bank3 static unsigned char arr3 ;

i dont get error message .

but when i m assigning a value by the line :

arr3='e';

i get the message :"fixup overflow in expression"

it really very annoying problem.......
:cry:


maybe its free version mplab disadvantage


avi.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top