- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Guys,
i'm new in using the EZ-USB FX3 SDK on an analog Device evaluation Board ADF4159. I want to develop a matlab Script that can be used to configure the board without a user intervention.
I find on others forum some codes that allows me to the CyUSB library. Actually i can connect To the board with the following command matlab script
:
try
CyUSBdll = NET.addAssembly('C:\Program Files (x86)\Cypress\EZ-USB FX3 SDK\1.3\application\c_sharp\streamer\bin\Release\CyUSB.dll');
catch error
error.message
if(isa(error,'NET.NetException'))
e.ExceptionObject
else
disp('CyUSB.dll already loaded');
return;
end
end
% Create a list of USB devices
usbDevices = CyUSB.USBDeviceList(CyUSB.CyConst.DEVICES_CYUSB);
% USB Device Count
num_usbDevices = usbDevices.Count; % <=== returned 1 when the device is plugged in, 0 when it's not.
usbDevice = usbDevices.Item(0)
Firmware_Path = 'C:\Program Files (x86)\Analog Devices\ADF4158-9\adf4xxx_usb_fw_2_0.hex';
if (~isempty(usbDevice))
disp('Device Connected succefully !')
% Load the firmware of the device ADF4159
FirmwareLoaded = usbDevice.LoadExternalRam(Firmware_Path);
% usbDevice.Reset();
% usbDevice.Dispose();
end
My question is how can i write to the register of the ADF4159 (https://www.analog.com/media/en/technical-documentation/data-sheets/ADF4159.pdf).
i tried this example in Matlab, but nothing seems to happen. Have you some idea of how i can shape data and send it to the component?
for ii = 1:4
buffer(ii) = uint8(0);
usbDevice.ControlEndPt.Target = CyUSB.CyConst.TGT_DEVICE;
usbDevice.ControlEndPt.ReqType = CyUSB.CyConst.REQ_VENDOR;
usbDevice.ControlEndPt.Direction = CyUSB.CyConst.DIR_TO_DEVICE;
usbDevice.ControlEndPt.ReqCode = uint8(hex2dec('DD')); %% DD references the function in the firmware ADF_uwave_2.hex to write to the chip
usbDevice.ControlEndPt.Value = 0;
usbDevice.ControlEndPt.Index = 0;
buffer(5) = uint8(32);
buffer_length = 5;
XferSuccess = usbDevice.ControlEndPt.XferData(buffer, buffer_length);
end
Hope somebody can help.
Best regards !
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
-Please let us know what the return code is on the host for the XferData call to the device.
-Please also share the firmware source that you are loading to check how the data is sent to ADF4159 once received by FX2LP.
Best Regards,
Sananya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
- Can you please let us know how is the vendor command 0xDD is implemented in the firmware? Do you need to send 5 bytes (buffer)?
- Also let us know which Cypress controller does it have. Is it FX2LP/FX3?
Regards,
Hemanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Hemanth,
yeas i think a 5 bytes buffer have to be sent. Here is the C# command.
private void WriteToDevice(uint data)
for (int i = 0; i < 4; i++)
buffer = (byte)(data >> (i * 8));
usbDevice.ControlEndPt.Target = CyConst.TGT_DEVICE;
usbDevice.ControlEndPt.ReqType = CyConst.REQ_VENDOR;
usbDevice.ControlEndPt.Direction = CyConst.DIR_TO_DEVICE;
usbDevice.ControlEndPt.ReqCode = 0xDD;
usbDevice.ControlEndPt.Value = 0;
usbDevice.ControlEndPt.Index = 0;
buffer[4] = 32;
buffer_length = 5;
XferSuccess = connectedDevice.ControlEndPt.XferData(ref buffer, ref buffer_length);
end
end
For the device, it the FX2 but the usbDevice.DriverName is CyUSB3.sys
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
-Please let us know what the return code is on the host for the XferData call to the device.
-Please also share the firmware source that you are loading to check how the data is sent to ADF4159 once received by FX2LP.
Best Regards,
Sananya