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.

TMS320F28069: USB communication between µC and Windows 10 64 Bit - Read Access Violation

Part Number: TMS320F28069
Other Parts Discussed in Thread: C2000WARE

Hello,

we are developing a GUI application on Windows in 64 Bit which is supposed to communicate with a microcontroller via USB 2.0 using C++  in Visual Studio 2022. We have previously asked for assistance in regards to providing a 64 Bit version of the tiusbdll functionality. We are currently using the file shared in the response marked as answer in the post below:

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1175659/tms320f28069-usb-communication-between-c-and-windows-10-64-bit---64-bit-driver-needed/4430883#4430883 

In order to initialize the communication, we roughly follow the order of usb_bulk_example.c found in C2000Ware Version 3.02.00.00 under utilities/tools/f2838x/usb_bulk_example of calling InitializeDevice() to set the TIUSB_HANDLE hUSB and use it to call WriteUSBPacket() with the appropriate function arguments. In our case, this is only sending 2 bytes which do get sent according to our monitoring of the PC side USB port with WireShark and do arrive according to a debugging mode monitoring the buffer in the microcontroller.

However, calling ReadUSBPacket() to read the returned data results in an unexpected Access Violation Exception during a read operation called by winusb.dll which is in turn called by tiusbdll.dll, before any response can be sent by the microcontroller. 

As we do have a working communication protocol based on 32 Bit tiusbdll written in C from a previous project, we can confirm that the microcontroller can send back the requested data when instructed through the 32 Bit protocol, which can be seen in WireShark as well. The function call of ReadUSBPacket() is identical to the one we are trying to implement in the 64 Bit version, including all function arguments. 

Is it possible that something changed in the recompilation of the dll-file for 64 Bit that could prevent only the read operation from working the same way as before? Please feel free to ask if you need further clarification. 

Thank you in advance and best regards.

Edit 02/23/2023: We have tested further and thought of the possibility that we may need to declare or initialize certain variables used in the function calls differently in 64 Bit than in 32 Bit (e.g. regarding buffer size, address types etc.). Is it possible that anything like that has to change to accomodate the switch to 64 Bit?

Additionally, is it possible that the driver files ucrtbased.dll or vcruntime140d.dll that are installed in folder Windows/system32/ for the 32 Bit protocol, have to be changed or installed elsewhere for the 64 Bit version?

  • Hi,

    Do you get any exception code for the access violation when the ReadUSBPacket is invoked? - It might help in figuring out what is causing this issue.

    I don't have indepth knowledge  on Win USB APIs . Will look into it and suggest ay resolutions to this issue.

    Best Regards

    Siddharth

  • Hello Siddharth,

    whenever the Access Violation happens, the exception code and description are usually something like "0xC0000005: Read Access Violation at position 0x0000000000000000" though the address at the end has differed on multiple occasions. 

    Additionally, after more testing on our end on some occasions, the Read operation does not throw the above exception, but USB monitoring via Wireshark also shows no traffic between the two devices. Reading the resulting error message from the returned DWORD dwError, g_pcErrorString has shown "Wrong Parameter" and "Invalid Handle" as reasons for not completing the read operation. However, we do not change the hUSB handle at all between the write and read function calls.

    Thank you for your help in this matter.

    Best Regards

  • Hello Andreas, 

    I went through the code for the DLL and the ReadUSBPacket invokes the WinUsb_ReadPipe function to read the data. This takes the same parameter for the USB handle , hence not sure why it is complaining about Wrong parameter.  I could not find anything specific to be done for 64-bit in the WinsUSB APIs.  Can you try posting it on the Microsoft forum and see if they can provide any pointers to handle this issue?

    Best Regards

    Siddharth 

  • Hello Siddharth,

    thank you for looking into the issue from your end. At least this way, we can eliminate one possible cause and focus our efforts in other directions.

    Best Regards

  • Hello Andreas, 

    I don't have any other suggestions at this point. Will keep looking for a solution and let you know if I figure out something.

    Best Regards

    Siddharth