Using Matlab to read and write to CY7C68013-CSP microcontroller

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
FaHo_4644226
Level 1
Level 1
First like given

I am about to implement some software using Matlab to communicate with my I2C Hardware (AD5933 Evaluation board) using the CY7C68013-CSP microcontroller utilizing vendor requests. To my understanding, before I can actually begin reading and writing, I must use the vendor command A0 to place the 8051 in RESET mode by writing 0x01 to the register 0XE600. I utilized the XferData() command to send this request and I also set all the required parameters before (i.e. Target, ReqType, Direction, ReqCode, Value, Index). However the XferData returns false in workspace (see attached images). I tried increasing the timeout and it still returned false. Some assistance would be greatly appreciated. 

0 Likes
1 Solution

Hello,

You can use the reset() or ResetFX2() function to hold the cpu in reset. Please refer to the CyUSB.NET.pdf document in the FX3 SDK

path: <installation directory>\Cypress\EZ-USB FX3 SDK\1.3\doc\SuiteUSB

passing a value 1 will halt the CPU and passing a value 0 will release the CPU.

If you need to send vendor commands separately to hold the CPU in reset you can try the below.

          

            byte[] dta = new byte[8];

            ControlEndPt.Target = CyConst.TGT_DEVICE;

            ControlEndPt.ReqType = CyConst.REQ_VENDOR;

            ControlEndPt.Value = 0xE600;

            ControlEndPt.Index = 0x0000;

            ControlEndPt.ReqCode = 0xA0;

            dta[0] = (byte)1/0; (reset condition 1 to halt and 0 to recover the CPU)

            int len = 1;

            ControlEndPt.Write(ref dta, ref len);

Best Regards,

Yatheesh

View solution in original post

0 Likes
9 Replies
YatheeshD_36
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hello,

The vendor command 0XA0 is used to load firmware to RAM and the CPU should be in reset during this process. Refer to control center application, which is available in the FX3 SDK for developing a custom firmware update tool.

Please refer to this KBA: Examples showing how to download firmware to a EZ-USB (AN21xx/FX/FX1/FX2/FX2LP)

Best Regards,

Yatheesh

0 Likes

Hi Yatheesh, thanks for the reply. I tried utilizing the control center C# code however it was pretty lengthy and I am not that familiar with the syntax. Is there any other examples/resources you can point me towards?

0 Likes

Hello,

Can you please confirm if you are developing a firmware update tool. If yes, then we you can refer to the fwdownload_fx2 application from the FX3 SDK present in the path:  <installation directory>\Cypress\EZ-USB FX3 SDK\1.3\application\cpp\fwdownload_fx2.

If you are developing an application to control the firmware flow, like sending packets to control end point etc.. and handling it in the firmware   then you can refer to the bulkloop and streamer applications present in the above path.

Thanks,

Yatheesh

0 Likes

Thanks again for the reply. I am trying to write I2C commands to an Impedance Analyzer chip which is connected to the I2C bus of the CY7C68013-CSP which requires vendor commands. The reason why I am using the A0 command is not to upload or download firmware to RAM, its to RESET the CPUCS (0XE600) by writing '1' to it so I can begin to write to registers. Which resource would you recommend?

0 Likes

Hello,

Can you please let me know which resistors you want to write to and your application?

Best Regards,

Yatheesh

0 Likes

Hi Yatheesh,

The application is to control the AD5933 impedance analyzer on the evaluation board (EVAL-AD5933) using an Arduino via Matlab to produce a frequency sweep. The registers I must write to are:

1. Control Register - 0x80, 0x81

2. Start frequency register - 0x82, 0x83, 0x84

3.Frequency increment register - 0x85, 0x86, 0x87

4. Number of increments register - 0x89

0 Likes

Hello,

You can use the reset() or ResetFX2() function to hold the cpu in reset. Please refer to the CyUSB.NET.pdf document in the FX3 SDK

path: <installation directory>\Cypress\EZ-USB FX3 SDK\1.3\doc\SuiteUSB

passing a value 1 will halt the CPU and passing a value 0 will release the CPU.

If you need to send vendor commands separately to hold the CPU in reset you can try the below.

          

            byte[] dta = new byte[8];

            ControlEndPt.Target = CyConst.TGT_DEVICE;

            ControlEndPt.ReqType = CyConst.REQ_VENDOR;

            ControlEndPt.Value = 0xE600;

            ControlEndPt.Index = 0x0000;

            ControlEndPt.ReqCode = 0xA0;

            dta[0] = (byte)1/0; (reset condition 1 to halt and 0 to recover the CPU)

            int len = 1;

            ControlEndPt.Write(ref dta, ref len);

Best Regards,

Yatheesh

0 Likes

Appreciate it man! Just to confirm, these same vendors commands are used to write/read I2C commands also with which vendor commands?

0 Likes

Hello,

Yes, the same vendor commands can be used but with a different request code and value for your application for I2C read/write.

Refer to section 3.7 table 3-7 in the EZ-USB Technical Reference Manual which lists the reserved vendor requests, you can use any of the other vendor requests for your custom implementation.

In the firmware, you can handle your custom vendor requests through the switch statement (switch(SETUPDAT[1])) in the DR_VendorCmnd() function. Refer to the vend_ax project in the FX2LP DVK firmware folder for examples.

Let me know if you have more queries.

Thanks,

Yatheesh

0 Likes