??? 07/07/08 14:16 Read: times |
#156478 - As Michael said.... Responding to: ???'s previous message |
For a start, an array is really just a concept for storing a number of variables. All the processor sees it as is numbers in memory locations. As Michael mentions, you need to know if interrupt functions are using the 8051's alternate registers - these live at memory locations 0x08 onwards to 0x1f. If perchance, there is an interrupt function using the alternate register banks, anything stored in internal memory locations 0x08..0x1f may get overwritten. You seem not to understand SFRs, stack and memory allocation. SFRs are special registers in the 8051 to talk to the internal timer,uart, ports etc. These can be accessed in 'c' otherwise you would not be able to achieve much otherwise. Also with stack - most of the time you don't need to worry about it, but understanding how it works is very useful. Arrays are usually not stored on the stack! I think you need to sit down and have a good read of your compiler manual and understand how it stores variables in memory and in the case of the 8051, which memory it is (we have three main memory areas - code,idata,xdata) and also the 8051 'bible' - look to the left hand side of this web page. Then get yourself a simulator and step through the code. It should all become perfectly clear. You also need to understand that you're working with a processor with a small amount of memory - this can get used up very quickly and weird problems like you describe can happen. |
Topic | Author | Date |
Data Array getting corrupted after init | 01/01/70 00:00 | |
OnePossibleIdea.... | 01/01/70 00:00 | |
I did not do anything with the stack | 01/01/70 00:00 | |
As Michael said.... | 01/01/70 00:00 | |
How do you test and debug code? | 01/01/70 00:00 | |
Keil is the only thing in place | 01/01/70 00:00 | |
'crap'?? | 01/01/70 00:00 | |
Is this the book you refer? | 01/01/70 00:00 | |
nope | 01/01/70 00:00 | |
Erik | 01/01/70 00:00 | |
So where is the code | 01/01/70 00:00 | |
do NOT "put them" | 01/01/70 00:00 | |
Focus | 01/01/70 00:00 | |
Simulator | 01/01/70 00:00 | |
So this is on a simulator? | 01/01/70 00:00 | |
Post your duff code | 01/01/70 00:00 | |
Finding Cause of Corruption | 01/01/70 00:00 | |
Get the C right, then look at the target CPU | 01/01/70 00:00 | |
Optimizing Compilers | 01/01/70 00:00 | |
In my experience..... | 01/01/70 00:00 | |
Keil C 51 Optimizations | 01/01/70 00:00 | |
Use IAR then | 01/01/70 00:00 | |
different approaches | 01/01/70 00:00 | |
sometimes, depends | 01/01/70 00:00 | |
Thanks![]() | 01/01/70 00:00 |