## Problem calling 32-bit SDK from MATLAB R2014b

gyellenXX
Newbie
Posts: 0
Joined: Thu Jul 30, 2020 8:27 pm

### Problem calling 32-bit SDK from MATLAB R2014b

I have used the TC08 via the SDK on a 64-bit Windows box. But on this 32-bit Windows 10 installation (64-bit hardware), I have been getting crashes with access violations when I use calllib to invoke any functions with passed arguments.

I can successfully load the library and call usb_tc08_open_unit, which returns the handle=1 and lights the LED on the device. The only other function I can call is usb_tc08_legacy_get_driver_version (which also takes no arguments). If I call usb_tc08_close_unit with the handle=1, the unit LED goes off, but MATLAB crashes with an access violation. Same for almost any other function.

Relevant code is:
TC08.lib = 'usbtc08';
'C:\Program Files\Pico Technology\SDK\inc\usbtc08.h');
TC08.h = calllib(TC08.lib,'usb_tc08_open_unit');
ret = calllib(TC08.lib,'usb_tc08_set_channel',TC08.h,1,uint8('K'));

(The last line crashes)

I have used this code fine with MATLAB R2019a and the 64-bit SDK.

gyellenXX
Newbie
Posts: 0
Joined: Thu Jul 30, 2020 8:27 pm

### Re: Problem calling 32-bit SDK from MATLAB R2014b

I think the problem is the calling convention: possibly MATLAB is expecting __cdecl but the library uses __stdcall. I will see if I can get this to work by using the advice in
https://www.mathworks.com/matlabcentral ... 7-6-r2008a

gyellenXX
Newbie
Posts: 0
Joined: Thu Jul 30, 2020 8:27 pm

### Re: Problem calling 32-bit SDK from MATLAB R2014b

I can confirm that this was the problem, and that it runs ok with the fix described in the mathworks.com piece. I'm not sure exactly which combinations of MATLAB, operating system, and SDK have this problem, but it might be worth trying this if you see a similar crash.

NeilH
PICO STAFF
Posts: 202
Joined: Tue Jul 18, 2017 8:28 am

### Re: Problem calling 32-bit SDK from MATLAB R2014b

Hi

Our MATLAB addons are only supported from 2015b so we cannot guarantee performance on earlier versions. For 32 bit system we do recommend using 2015b 32-bit.

Neil
Neil
Technical Support Engineer