This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DDC1128EVM: Access violation executing USB_IO_for_VB6 on the DDC11128EVM on C++ visual studio 2013 and 2015

Part Number: DDC1128EVM

Hi, I'm A. Salas.

Although with Visual Basic I have managed to run USB_IO_for_VB6.dll with the help of the "DLL User Guide for  DDC1128EVAL module.pdf" to execute functions such as WriteFPGARegsC, I'm not able to do it using C++ in visual studio 2013 nor 2015.

I wonder if someone has done this and can provide an example. It should be an easy process if there was a header file and a lib file to add to the C++ project, but it seems that TI does not provides those files. This makes usage on C++ a bit more complex.

To expand on the error I'll provide more details:

I get the following error: 

"Exception thrown at 0x10001B92 (USB_IO_for_VB6.dll) in DDC1128EVM.exe: 0xC0000005: Access violation reading location 0x00000000. If there is a handler for this exception, the program may be safely continued."

I've tried with visual studio community 2013 and also visual studio community 2015 with the same error.

To load the DLL I use  LoadLibrary(DllPath);

If successful I then find the address of the function  within the DLL using GetProcAddress();

This is also successful because the address returned by GetProcAddress(), matches the address shown using a third party app mentioned here in this forums named  "dependency walker".

So, after successfully loading the DLL and successfully retrieving the address of the function to run,  I try to execute the function and I get the Access Violation error exactly on the address of the DLL.

As an example here is the code I'm using to load the DLL:

this is some where else in the code: 


typedef int(*XferINTDataIn_def)(int *USBdev, int *INTData, long *DataLength);

extern "C" int XferINTDataIn(int *USBdev, int *INTData, long *DataLength);

and this is where the exception is thrown:

void CDDC1128EVMDlg::OnBnClickedButton2()
{
	CString str;

	HINSTANCE hResDDC1128DLL = NULL;
	LPCTSTR DllPath(_T("C:\\src\\vs2013\\libs\\DDC1128\\\USB_IO_for_VB6.dll"));
	hResDDC1128DLL = LoadLibrary(DllPath);
	if (!hResDDC1128DLL)
	{
		str.Format(_T("Error: Cannot find component %s"), DllPath);
		AfxMessageBox(str);
	}
	else

	{
		XferINTDataIn_def xferInt;
		xferInt = (XferINTDataIn_def)GetProcAddress(hResDDC1128DLL, "XferINTDataIn");
		str.Format(_T("GetProcAddress: %d, GetProcAddress: %d."), xferInt, hResDDC1128DLL);
		AfxMessageBox(str);
		if (NULL != xferInt)
		{
			long DataLength_long(1);
			int dataread[10] = { 0 };
			int transfered(0);
			transfered = xferInt(0, dataread, &DataLength_long);
			//int __stdcall XferINTDataIn(int *USBdev, int *INTData, long *DataLength);
			//int respVal(0);
			str.Format(_T("tranfered: %d"), transfered);
			AfxMessageBox(str);
		}
		FreeLibrary(hResDDC1128DLL);
	}
}

here is an image of how  dependency walker shows the addresses of the functions and also an image of the error and the code.