View previous topic :: View next topic |
Author |
Message |
albus
Joined: 13 Apr 2013 Posts: 8
|
Struct Array and Item not within memory block |
Posted: Thu Apr 18, 2013 5:05 am |
|
|
I'm using PCWHD 4.138 compiler and writing a program. I've had to define some structs in the code, which are this;
Code: | typedef struct
{
int hour;
int min;
int sec;
} chrono;
typedef struct
{
int hour;
int min;
int sec;
int1 enable;
} time;
typedef struct
{
char UserName[MAX];
char Password[MAX];
time instance_list[INSTANCE_SIZE];
chrono hist_list[HISTORY_SIZE];
int1 valid;
int counter;
} user;
|
I have an array that keeps user structs, which is declared like this;
Code: | user List[MAX_USERS]; |
There seems to be a problem though, when I try to simulate it on Proteus. The addresses of variables in the List array seems to be overlapping, which causes undefined behavior.
I've googled the error not within memory block but couldn't find anything. Plus proteus seems to be thinking that one element of the user List is 84 bytes, which is way more than the real value. I've tried it with both PIC16F877 and PIC18F4620 |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9244 Location: Greensville,Ontario
|
|
Posted: Thu Apr 18, 2013 5:23 am |
|
|
simple answer..
please read PIC101 sticky.
Your problem is inside Proteus,well known flaws exist within.Why 'everyone' thinks it's perfect is beyond me as it can't simulate any PIC properly.
This is NOT a Proteus forum,and no one here will waste their valuable time trying to patch Proteus.
I strongly suggest getting real PICs,write real code,burn the PIC and see what happens in the real world.After you do those 3 steps,report back, and several of the 'gang' will be able to show you how to get your code 'up and running'.
hth
jay |
|
|
albus
Joined: 13 Apr 2013 Posts: 8
|
|
Posted: Thu Apr 18, 2013 5:28 am |
|
|
Chill man,
I know that proteus is flawed. For starters, it doesn't even recognize int1 data type.
It's just that I'm using struct in struct and arrays in arrays. That's why I asked if this might occur because of a flaw in code. I'll try it in real life and report back.
Edit: So I tried it on real hardware and there was no problem and for some magical reason even though cpu variables are still shown as in the picture, it worked fine in Proteus also.
In other words, problem solved. |
|
|
|