admin管理员组文章数量:1391947
I'm running into a situation where I seem to be on the edge of having enough variable space. I don't know if I'm running into a limit in SDCC, or how to handle this or check where the issue is located.
The microcontroller is an STC89c58RD+ at 11.0592Mhz.
I compile using the line below, it works until I add line 130 in main.c, this takes it over the edge, I compile without an error, yet this will only run upto 130 and it will "stop". If I comment out line 130, the code runs again, if I add another variable for the SD card driver I ported, it does the same thing, just stops and appears to have "left the planet", no indications of activity.
sdcc --debug --std-sdcc23 --iram-size 256 --xram-size 1280 --code-size 32512 --nooverlay --model-large main.c -o mainL.ihx SDtestL.lib oledL.lib -L ..\..\00_SDCCnewLibs -I ..\..\00_SDCCnewLibs
Internal RAM layout:
0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00:|0|0|0|0|0|0|0|0|a|a|a|a|a|a|a|a|
0x10:|a|a|a|a|b|b|b|b|b|b|b|b|b|c|f| |
0x20:|B|d|d|d|d|d|d|d|d|e|e|e|e|Q|Q|Q|
0x30:|Q|I|I|I|I|I|I|I|I|I|I|I|I|S|S|S|
0x40:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x50:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x60:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x70:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x80:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x90:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xa0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xb0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xc0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xd0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xe0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xf0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0-3:Reg Banks, T:Bit regs, a-z:Data, B:Bits, Q:Overlay, I:iData, S:Stack, A:Absolute
Stack starts at: 0x3d (sp set to 0x3c) with 195 bytes available.
The largest spare internal RAM space starts at 0x1f with 1 byte available.
Other memory:
Name Start End Size Max
---------------- -------- -------- -------- --------
PAGED EXT. RAM 0 256
EXTERNAL RAM 0x0001 0x00b4 180 1280
ROM/EPROM/FLASH 0x0000 0x21a9 8618 32512
Enabling line 130, which is a call to a function returning a humidity and temperature. When this is enabled, memory is per below, I believe that I am in the range of memory available but I'm not allowed the extra variable. I'm trying to figure out if XRAM is not working for this chip, the checkbox in STC-ISP is enabled for XRAM. It looks like I should have more variable room as I have compiled for Large which should push all variables to XRAM (XDATA).
Internal RAM layout:
0 1 2 3 4 5 6 7 8 9 A B C D E F
0x00:|0|0|0|0|0|0|0|0|a|a|a|a|a|a|a|a|
0x10:|a|a|a|a|b|b|b|b|b|b|b|b|b|c|f| |
0x20:|B|d|d|d|d|d|d|d|d|e|e|e|e|Q|Q|Q|
0x30:|Q|I|I|I|I|I|I|I|I|I|I|I|I|S|S|S|
0x40:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x50:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x60:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x70:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x80:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0x90:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xa0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xb0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xc0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xd0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xe0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0xf0:|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|S|
0-3:Reg Banks, T:Bit regs, a-z:Data, B:Bits, Q:Overlay, I:iData, S:Stack, A:Absolute
Stack starts at: 0x3d (sp set to 0x3c) with 195 bytes available.
The largest spare internal RAM space starts at 0x1f with 1 byte available.
Other memory:
Name Start End Size Max
---------------- -------- -------- -------- --------
PAGED EXT. RAM 0 256
EXTERNAL RAM 0x0001 0x00c3 195 1280
ROM/EPROM/FLASH 0x0000 0x23a6 9127 32512
I have tried to add different variables or calls to other functions, these are working functions but adding either variables or function calls, the code will stop on the line added. I debug with a putchar()
before and after, the before message comes out, the putchar()
after the variable is never seen. I've looked around and found messages to a stack issue, but I don't get the errors related to a stack failure in the .mem
file, but it feels like something like this is the issue. I need some shots on how to solve this. From the .mem
file, I'm not running out of memory, which makes this more confusing.
Compile line:
sdcc --debug --std-sdcc99 --model-large main.c -o mainL.ihx oledL.lib -L ..\..\00_SDCCnewLibs -I ..\..\00_SDCCnewLibs
Test code that breaks:
//..section of a loop to read temperature and display it
OLED3_DisplayNumber(10, i, 2);
DELAY_ms(400);
cksum = DHT_GetData( & dht); // <-- going to this function is where it stops
Part of the function called:
//..part of the function being called from a library (compiled '--model-large'
int DHT_GetData(dht_t *dht) {
DELAY_ms(200); //wait 200 ms for stable signal
Request(); // send start pulse
Response(); // receive response
I_RH = Receive_data(); // have to read then send to struct, timing issue
D_RH = Receive_data(); // store next eight bit in D_RH
I_Temp = Receive_data(); // store next eight bit in I_Temp
D_Temp = Receive_data(); // store next eight bit in D_Temp
CheckSum = Receive_data();
dht->h1 = I_RH; // store first eight bit in I_RH dht->h1;
dht->h2 = D_RH; // store next eight bit in D_RH
dht->t1 = I_Temp; // store next eight bit in I_Temp
dht->t2 = D_Temp; // store next eight bit in D_Temp
dht->crc1 = CheckSum; // store next eight bit in CheckSum
if ((I_RH + D_RH + I_Temp + D_Temp) != CheckSum) {
return (99);
} else {
return (CheckSum);
After some feedback, the issue appears to be related somehow to compiling with --model-large, the code always worked with --model-small.
The question I seem to need to figure out is what happens with going to --model-large, I will need to figure out this step. The next step will be adding an SD driver/library which will increase number of variables. Will the 8051/SDCC be able to do this, I'm still optimistic?
本文标签: Can39t add more variables in 8051 programStack Overflow
版权声明:本文标题:Can't add more variables in 8051 program - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744724803a2621902.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论