PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 04, 2010 11:59 pm |
|
|
Post a test program, in which you initialize those 3 structure elements
to some value, and then run the foo() function, and then display the
results of reading the structure elements. Something like this:
In other words, demonstrate the problem. Post the "before" and "after"
results of running the foo() function.
Code: |
#include <18F2620.h>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
typedef struct
{
int1 open;
int32 holdSect;
int8 index;
int8 ttribute;
int32 orgSect;
int32 curSect;
int32 size;
int32 x;
int16 xLocal;
char name[8+3];
}st_fileptr;
//st_fileptr g_fp;
st_fileptr g_fp = {
1, // open
0x01234567, // holdSect
0x55, // index
0xAA, // ttribute
0x00112233, // orgSect
0x44556677, // curSect
0x8899AABB, // size
0x89ABCDEF, // x
0x10A9, // xLocal
{"Filename"}
};
void foo( void )
{
st_fileptr *d;
d = &g_fp;
//d = &(st_fileptr *)g_fp;
d->size = 0x12345678;
d->curSect = 0x89ABCDEF;
d->orgSect = 0x98765432;
}
//=============================================
void main(void)
{
printf("size = %lx \r", g_fp.size);
printf("curSect = %lx \r", g_fp.curSect);
printf("orgSect = %lx \r", g_fp.orgSect);
foo();
printf("size = %lx \r", g_fp.size);
printf("curSect = %lx \r", g_fp.curSect);
printf("orgSect = %lx \r", g_fp.orgSect);
while(1);
}
|
|
|