1). how to solve the problem of auto segment to large.?
2)how to dynamically allocate memory in keil? malloc etc. functions are concerned with c. but can we use 'new' operator in keil when programing using C++. is there any other method with c++ in keil to dynammically allocate memory?
1) malloc is wisely outlawed by MISRA and IMHO blatantly violating MISRA is fools errand 2) using malloc in C51 is ridiculous, the underlying processor is singularly unsuitable for this. 3) is sounds as if you need to switch to an ARM
is there no other way to dynamically allocate memory in c51.my project is based on c51.
You can always write your own code, optimizing it for your specific requirement.
Obviously: use less auto data!
Remember that Dynamic Allocation does not magically create more RAM! To use dynamic allocation, you will have to reserve space for the Heap - which means that less space is available for other things.
And dynamic allocation adds its own overheads - so you will actually end up with less available RAM!
ok, let me tell u the root cause, i am using 7 arrays like unsigned char arr[]., each array with more than 60 elements , it shows sdress space overflow. i want to get rid of this....
i am using 89c51 mic. controller.
and please also tell how to use Hdata in keil with c++ language. which file to include etc
i am using 89c51 mic. controller. which of the 4711 derivatives? Get a chip with enough RAM e.g.SiLabs f5xx
and please also tell how to use Hdata in keil with c++ language. which file to include etc C51 does AFAIK not know what HDATA is
"7 arrays like (sic) unsigned char arr[]."
What do you mean, "like"? Are they unsigned char, or are they not?
"each array with more than 60 elements"
What do you mean, "more than"? The 'C' programming language does not allow arrays of indeterminate length - you must know how long they are!
If we just take the 60, then 7 x 60 = 420 bytes for the arrays
"it shows sdress space overflow"
Which address space, exactly, has the overflow?
Copy and paste the full text of the message - don't try to paraphrase or manually re-type it.
"i am using 89c51"
Do you mean an NXP (formerly Philips) P89C52: http://www.keil.com/dd/chip/3216.htm "P89C51RD2xx is an 8051 based CMOS controller with PCA, Dual DPTR, WDT, 32 I/O lines, 3 Timers/Counters, 7 Interrupts/4 Priority Levels, 64K Bytes ISP FLASH, 256 Bytes on-chip RAM, 768 Bytes XRAM."
Or a Microchip (formerly Atmel) AT89C52: http://www.keil.com/dd/chip/2980.htm "AT89C52 is an 8051-based Fullly Static 24MHz CMOS controller with 32 I/O Lines, 3 Timers/Counters, 8 Interrupts/2 Priority Levels, UART, Three-Level Program Memory Lock, 8K Bytes Flash Memory, 128 Bytes On-chip RAM."
Clearly, neither of these has space to fit over 420 bytes into internal RAM; so, if you're trying to do that, you will obviously fail - with an overflow!
If you have the NXP chip, you have the option to use XRAM - but not on the Microchip chip.
"please also tell how to use Hdata in keil with c++ language"
You can't - C51 is not a C++ compiler!
thanks for ur help... i have solved the problem...