Hi.
I ask couple of days ago about unexplained code behavior. It hasn't been solved completely.
I now have some more specific details about that.
Function InitDeviceasBC call function sitalDevice_Initialize.
When sitalDevice_Initialize returns addresses of local variables in InitDeviceasBC suddenly changed.
InitDeviceasBC :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
void InitDeviceAsBC()
{
unsigned int uiDeviceCount = 1;
unsigned int uiDeviceID = 0;
U16BIT NumberOfDevices = 0;
S16BIT iResult = sitalDevice_GetCount(&NumberOfDevices);
printf ("Device Count: %i\n", NumberOfDevices);
for(int idx = 0 ; idx < 1/*NumberOfDevices*/ ; idx++){
uiDeviceID = idx;
printf("\nuiDeviceID before device_initialize: %p\n\r",&uiDeviceID);
printf("\nNumberOfDevices before device_initialize: %p\n\r",&NumberOfDevices);
iResult = sitalDevice_Initialize(uiDeviceID, sitalAccess_CARD, sitalMode_BC, 0, 0, 0);
if(iResult != 0)
{
printf("sitalDevice_InitializeBC.Error: %i", iResult);
return;
}
printf("\nuiDeviceID after device_initialize: %p\n\r",&uiDeviceID);
printf("\nNumberOfDevices after device_initialize: %p\n\r",&NumberOfDevices);
iResult = sitalDevice_TimeTag_SetResolution(uiDeviceID, sitalTimeTagResolution_64US);
if(iResult != 0)
{
printf("TimeTag_SetResolution Error: %i", iResult);
return;
}
printf ("Time Tag resolution of %i\n", sitalTimeTagResolution_64US);
iResult = sitalDevice_Irq_Manipulate(uiDeviceID, 1, sitalInterruptRegister2_BC_IRQ3, &funcExternalISR);
if(iResult != 0)
{
printf("sitalDevice_Irq_Manipulate Error: %i", iResult);
return;
}
printf ("sitalDevice_Irq_Manipulate %i\n", iResult);
}
}
| |
sitalDevice_Initialize :
S16BIT _DECL sitalDevice_Initialize ( S16BIT swDevice,
U16BIT wAccess,
U16BIT wMode,
U32BIT dwSizeOfAllocatedMemory,
U32BIT dwRegistersAddress,
U32BIT dwMemoryAddress)
Definition is too long..
I check memory address of variables before and after call to sitalDevice_Initialize:
uiDeviceID before device_initialize: 0x191154
NumberOfDevices before device_initialize: 0x191174
uiDeviceID after device_initialize: 0x190028
NumberOfDevices after device_initialize: 0x190048
notice a similar offset between vatiables old and new address.
Is this indicating about wrong stack frame?
Any help will be appreciated.