Forums

strange var assignments in CW5.0.4 w/sdk 2.5 - dsp56807

Started by vagenta May 9, 2003
I am having very odd variable assigments when using the debugger.
Multipart question:

1. First with #defines.
In order to access a direct memory location on the external data
memory space say at $C008 and $C00A, in order for our external logic
to interpret the data, we have been using #defines in our header
files to direct this.
whatever.h or appconst.h
{
#define DEV_TEC2_DAC ((UInt16 *)0xC008)
#define DEV_TEC2_DACLOAD ((UInt16 *)0xC00A)

or
UInt16* DEV_TEC2_DAC = ((UInt16 *)0xC008);
UInt16* DEV_TEC2_DACLOAD = ((UInt16 *)0xC00A);

}

Then when a calling function passes a pointer to this location(var)
sometimes it passes the address correctly other times not. As in:
Calling function:
whatever.c
{
UInt16 DACTestValue = 0x02AA;

TECSendData((UInt16*)DEV_TEC2_DAC,(UInt16*)DEV_TEC2_DACLOAD,
DACTestValue);

or
TECSendData(DEV_TEC2_DAC, DEV_TEC2_DACLOAD, DACTestValue);

}

function:
tecsenddata.c

void TECSendData(UInt16* pTecDac,UInt16* pTecDacLoad, UInt16
TECDAQInput)
{
UInt16 WriteValue = 0x0800;
UInt16 stepsize = 50;
Int16 i = 0;
Int16 idx = 0;
Int16 counter = 0;
Int16 loopwait = 100;

// handle the pointers/parameters here
...
}

The problem is that the parameters pTecDac, pTecDacLoad and
TECDAQInput in the function TECSendData() are often corrupted, but
not necessarily all of them. Quite often, only the parameter
pTecDacLoad var will pass the address correctly while the other two
parameters will come out 0xFFFF while in the debugger.

2. Now for my second part of the question:
These local variables within this last function are often not
initialized properly to the values I have specified above.
In the debugger it will instead have them initialized as follows:
stepsize = 65535;
Int16 i = 0;
Int16 idx = 0;
Int16 counter = -1;
Int16 loopwait = -1;

Do you have any ideas why this would be acting like this? I have a
great 38kB gif screen shot available if I knew where to post it.

Thank you,
Brian