PICcoder.co.uk Forum  


::post new topic::
FullSpeed USB
Date: 2007/10/15 20:52 By: A Critchley Status: Visitor  
 
I am trying to communicate with PICDEM USB DEMO from a Delphi program
as follows:-

unit FSUSB;

interface

uses Windows, SysUtils;

function _MPUSBGetDeviceCount(pVIDPID: PCHAR)WORD; stdcall; external 'mpusbapi.dll';

procedure GetCount;

const vidpid: PChar = 'vid_04d8&pid_000c';

var temp: dword;


implementation

uses MLP;

procedure GetCount;
var i, j:byte;
begin
j:= 0;
temp:= _MPUSBGetDeviceCount(vid_pid);
for i:= 0 to 6 do inc(j); {just somrthing to do}
Form1.Edit4.Text:= IntToStr(temp); {put breakpoint on this line}
end;

end.


This routine compiles and runs OK to the marked breakpoint. The correct value is in temp and the loop shows that the routine is still running ok. If I cause the routine to exit by hiting F7 twice I get the error :-

access violation at 0x12f56f: write of address 0x8812b1d1
00 60 F7 12 00 78 B0 DA 00 18 B9 42

I am assuming that as the routine is OK until it is exited that the stack has
not been correctly restored after the call to the dll. Could the dll be faulty? or am I calling it incorrectly?
reply | quote

::post new topic::