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.

Auto segment too large

Status
Not open for further replies.

Maverickmax

Advanced Member level 1
Joined
Dec 6, 2004
Messages
404
Helped
8
Reputation
16
Reaction score
3
Trophy points
1,298
Activity points
3,689
auto segment too large

Hi

I have been learning to use 128x64 LCD module with AT89C51 and I have been using FastLCD for converting bmp into a table of bytes.

I have use the table in my codes and tried to compile it uisng the Keil software. I get the result - auto segment too large.

How to put all bytes in my codes in order to display picture on my 128x64 LCD module.

I don't understand it. What is the problem?

Maverick Max

Added after 17 minutes:

I found the information about error but I don't understand. Can someone care to explain it to me?

Error C241
Summary

*** Error C241
Auto Segment Too Large

Description The required space for local objects exceeds the model dependent maximum. The maximum segment sizes are defined as follows: SMALL 128 bytes COMPACT 256 bytes LARGE 65535 bytes

https://www.keil.com/support/man/docs/c51/c51_c241.htm

Does this mean that the codes is too way too big for my microcontroller?

Maverick Max
 

keil segment too large

I have attached my codes here for you to check it out.

Since my AT89C51 lack sufficient data memory, do anyone know 8051 has 4k or more data memory ?

Maverick Max
 

error in c data: segment too large

Hi

Does AT89S8252 has sufficient data memory for storing 512 bytes?

Cuz I am a bit confused with 2K Bytes EEPROM and 256x8 Internal RAM!

How the heck can I store there?


Maverick Max :roll:
 

keil c error c241: : auto segment too large

Hi,

in write_display.c replace const tByte dot_0 [] with code const tByte dot_0 [] otherwise dot_o[] will be placed into ram ...

hope this helps
 

    Maverickmax

    Points: 2
    Helpful Answer Positive Rating
8051 bit addressable data segment too large

Hello C-man

I have not heard 'code' before. Can you please explain why you use 'code'?

I coud not find 'code' in my C books such as The Indispensable Guide to C and Guide to Beginner's C!

Where the heck 'code' comes from?! :cry:

Maverick Max
 

error c241 auto segment too large

This is rom the C51 manual:
3
Explicitly Declared Memory Types
By including a memory type specifier in the variable declaration, you may
specify where variables are stored.
The following table summarizes the available memory type specifiers.
Memory Type Description
code Program memory (64 KBytes); accessed by opcode MOVC @A+DPTR.
data Directly addressable internal data memory; fastest access to variables
(128 bytes).
idata Indirectly addressable internal data memory; accessed across the full internal
address space (256 bytes).
bdata Bit-addressable internal data memory; allows mixed bit and byte access
(16 bytes).
xdata External data memory (64 KBytes); accessed by opcode MOVX @DPTR.
pdata Paged (256 bytes) external data memory; accessed by opcode MOVX @Rn.
As with the signed and unsigned attributes, you may include memory type
specifiers in the variable declaration.

best regards
 

automatic data segment exceeds 64k

OK .. I WILL TRY TO EXPLAIN IT .. THE 51 is a MCU that has several memory SPACES .. CODE ,DATA ,IDATA ,XDATA AND PDATA .. when you create a VARIABLE ( a char or an ARRAY ) you have to tell the compiler where in wich one to PUT IT !
the 51 is a tricky MCU .So when dealing with large programs you need to be aware of the number of variables .
Example : lets say that you create variables in excess of 500 ! ..well now you have to custumize !
you only have 128 - internal registers in the DATA segment .. so you will affect here the most used variables ,the ones that require speedy access .You still have 128 bytes of RAM in the IDATA segment .So put here the second variables in priority. Finnaly the XDATA is the external RAM SEGMENT .. you have up to 64K space . Provided that you have PHYSICALLY that RAM .. some micros have 2k,8k or more ,Check the datasheet .
Now care must be paid when dealing with all this memory spaces .
because YOU CAN'T DO THIS :

xdata char *myram_ptr ;
idtata char *myidata_ptr;
char *mydata_ptr; <- deafult goes to data is the same as: data char *mydata_ptr;
code char *mycode_ptr;
pdata char *mypdata_ptr

*mycode_ptr = *myram_ptr or any combination of the above variables
they need to be casted properly. Because all the pointers are differently represented inside de compiler ..
So one thing is start with is as someone said is to put the constants in "code" space ,so they don't get map by default in RAM

so if you have
int pi = 31416 ;

code this as : code const pi = 31416; <-- it will be put in flash or rom segment
 

    Maverickmax

    Points: 2
    Helpful Answer Positive Rating
keil c auto segment too large

Blimey, I didn't know that 51 has four different memory spaces! But I get the general idea now.

Imagine if I have an external RAM memory with my microcontroller, do I have to use PDATA in order to store the data in the external RAM?

I would like to see example of using external ram with 89C51 in C because I want to learn it for my future project.

By the way, thank you for helping me to understand. You got 'helped me' points :)

Maverick Max
 

idata, pdata, xdata

Sorry i think i made a mistake ..with pdata is i think xdata .. but yes see your compiler doc to see how they access that space ..is simple ! .the thing is that is compiler dependant .

Pdata is the first 256 bytes of external ram .using the keil compiler
Xdata is the all the 64k

pdata is useful when you need a little variables ..

the reason is how the pointer is represented , it saves a lot of space by declaring it as pdata .. (the header is smaller)

but if you need more data ,,well go with xdata

exmp

xdata int myArray[1000] ;

here all this array needs to be precisely affected to xdata .and if you want to access it through a pointer you have to declare it as

xdata int myptr;;
now you can get the address by simply
myptr = myArray ;

Instead had you done this :

code int myptr ;
myptr = myArray ; the compiler will CRY !! both addresses correspond to different spaces ..so it needs to be cast as

myptr = (code int ) myArray ;

The best way to completly understand this is to read the POINTER section on the KEIL MANUAL .. then it becomes really clear how pointer works and HOW THEY ARE REPRESENTED (the pointer HEADER) among those spaces and why you just can't do "INDISCRIMINATE POINTING"

then all is simple ,,very simple
 

segment of program is too large

Since I am very new in this kind of area. I would like to give it a go asap. Do you have any schematic for connecting RAM memory? Where and which External memory I can buy?

What about codes? cuz I need some examples to understand better.

Maverick Max
 

error 49: data segment too large pointer

RAM is very fast this days .So any 8 bit 1 megabit or even 2 megabit static ram will do. The cheaper the better ! access time .It dependes how fast is your micro ,With non risc 51 .a 120 ns < will work just right! ..In any case all the manufacturers do at least 70ns this days anyways .. So you are safe !

So i will find you a schematic .. an i will post it .. but ant elektroda you can find a thouthand if you want to go faster !

There is one more SPACE in the 51 .Well is mapped in the DATA space also .but is good to know that it can also be used as a different space .This is the BIT space .
where you can affect boolean variables !

bit mytrue ;
bit mylie

mytrue = 0;
mylie = 1; <- this two variables can only take 1 or 0

but if you do :

true = 5 ; <-- the compiler will complain

in this space the variables can only take 1 or 0 ,, very useful and here you can save a lot of ram . Because the compiler will map those variables to bits in the data space .. ( only 20~30 bytes are avalaible for that )

so check what are your variables that are boolean and map them to the BIT segment !

Cheers!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top