6 Replies Latest reply on May 17, 2014 6:50 AM by vavc

    How to write FX2 registers using CyApi?

    jarno.rajala

      I'm trying to write the CY7C68013 registry through the control endpoint using ReqCode 0xA0. My purpose is to enable the slave FIFOs without programming the 8051. For some reason the following code doesn't work. Reading the register 0xE600 always produces 176 (0xB0). Writing to other areas of the RAM seems to work, e.g. writing to address 0, the written value is retained. Is there something missing from the code?

         

       

         

      #include "stdafx.h"
      #include <Windows.h>
      #include <conio.h>
      #include "CyApi.h"
      #include <iostream>

      using namespace std;

      int _tmain(int argc, _TCHAR* argv[])
      {
          CCyUSBDevice * usb = new CCyUSBDevice(NULL);

          usb->Open(0);

          UCHAR cpucs = 0;
          usb->ControlEndPt->Target = TGT_DEVICE;
          usb->ControlEndPt->ReqType = REQ_VENDOR;
          usb->ControlEndPt->ReqCode = 0xA0;
          usb->ControlEndPt->Value = 0xE600;
          usb->ControlEndPt->Index = 0;
          LONG len = 1;

          usb->ControlEndPt->Read(&cpucs, len);
          cout << "CPUCS: " << (int)cpucs << " " << len << "\n";;
          cout << "Clock:" << (((int)cpucs >> 3) & 3) << "\n";

          Sleep(1000);
          cpucs = 0x1;
          usb->ControlEndPt->Write(&cpucs, len);

          delete usb;

          cout << "Done\n";

          _getch();

          return 0;
      }
       

        • 1. Re: How to write FX2 registers using CyApi?
          content.librarian

          Hi,

             

           

             

          When you want to write something into the RAM, you have to keep the CPU in RESET by writing 0x01 to 0xE600 register by using 0xA0 vendor command. Please refer the Technical reference manual chapter Section 3.8. In your code it seems that the 0xA0 command is not sent to device(please correct me If I am wrong).

             

           

             

          Regards,

             

          Vikas

          • 2. Re: How to write FX2 registers using CyApi?
            vavc

            Hi,

               

             

               

            When you want to write something into the RAM, you have to keep the CPU in RESET by writing 0x01 to 0xE600 register by using 0xA0 vendor command. Please refer the Technical reference manual chapter Section 3.8. In your code it seems that the 0xA0 command is not sent to device(please correct me If I am wrong).

               

             

               

            Regards,

               

            Vikas

            • 3. Re: How to write FX2 registers using CyApi?
              jarno.rajala

              The code first reads, then writes. If I run the program again, the 8051 should still be in reset, shouldn't it? And I should be able to read the previously written content.

                 

              I've also tried changing the order, write first and for good measure, reassigning the Target, ReqType, etc. variables each time. If using 0xA0 I write 0x01 to 0xE600, as in the code. Shouldn't CLKSPD be set to 0. Why do I get 0xB0 when reading back the contents of 0xE600. Also I always get 0xB0 when reading address 0xE601, which is the IFCONFIG register.

              • 4. Re: How to write FX2 registers using CyApi?
                vavc

                Hi,

                   

                 

                   

                When you want to write into RAM you have to keep the CPU in reset and once it is done you have to make it to get out of reset by writing 0x00 to 0xE600 register. For reading the contents no need to keep the CPU in RESET.

                   

                 

                   

                Is there any EEPROM connected to the FX2LP? Is it programmed?may be the bootloader has loaded the contents on EEPROM inot RAM and the contents that you are trying to write is failed.

                   

                 

                   

                Can you take a trace?

                   

                 

                   

                For reference please refer the control centre source code in the path "C:\Cypress\Cypress Suite USB 3.4.7\CyUSB.NET\examples\Control Center"

                   

                 

                   

                the source code of CYAPI can be obtained from the FX3 SDK http://www.cypress.com/?rID=57990

                   

                 

                   

                Regards,

                   

                Vikas.

                • 5. Re: How to write FX2 registers using CyApi?
                  jarno.rajala

                  The device does not have an EEPROM connected, so it resets to the default firmware. I'm not sure what traces you mean. I've attached a picture showing the USB Control Center, where I've read 64 bytes starting from address E600. Other than the 8051RES bit, are these registers at all accessible via the 0xA0 request or do I need to upload my own 8051 firmware to program them?

                  • 6. Re: How to write FX2 registers using CyApi?
                    vavc

                    Hi ,

                       

                     

                       

                    Trace means USB trace. It captures the data that is going from PC to USB device.

                       

                     

                       

                    Could you please create tech support case    

                       

                              http://www.cypress.com/support so that one of our engineer will assist you further.

                       

                     

                       

                    Regards.

                       

                    Vikas..