1 Reply Latest reply on Nov 13, 2019 12:00 AM by RashiV_61

    FX3 - CyU3PGpifInitCtrlCounter API

    FaFi_4159091

      Hello,

       

      thanks to the help of this community my fx3 design is advancing quite well. Now I'm trying to configure the CTRL_COUNT in firmware rather than in the GPIF-Designer, since I want to be able to set the limit from my host application.

      What I've done so far:

       

      1. designed a state machine in the GPIF-Designer and added the LD_CTRL_COUNT action to a state, which is never reached. The counter is configured as an up-counter from 0 to 127. I had to do this, to be able to use the COUNT_CTRL action without errors in the GPIF-Designer

       

      2. In the firmware, I've used the CyU3PGpifInitCtrlCounter() API to override the counter settings. For simplification I've just hardcoded the counter to run from 0 to 63. Later this value shall by configured via the host application before the GPIF is loaded/startet.

       

      Based on the documentation, the CyU3PGpifInitCtrlCounter() API should override the counter configuration, but it does not work for me.

        • 1. Re: FX3 - CyU3PGpifInitCtrlCounter API
          RashiV_61

          Hello Fabian,

           

          You need to add LD_CTRL_COUNT because by default the GPIF_CTRL_COUNT_CONFIG register is set to accept only changes by hardware (from the GPIF). When you call this CyU3PGpifInitCtrlCounter() API it sets the SW_RESET field (to accept counter reset/load from software).  (Refer attachment)

           

          1) If in CyU3PGpifInitCtrlCounter() the reload field is set to CyFalse, you need to load the the counter before it reaches the state where counter starts. This can be the case where you don't want to keep the counter limit same every time.

           

          Please refer to the GpifToUsb_CTRL_COUNTER.zip

          Just for testing purpose I have modified the default firmware and GPIF state machine. There is INTR CPU when counter hits the limit value. In the GPIF callback, the counter value is loaded again. Whenever the GPIF callback is registered, a flag is incremented and it's value is printed later in the for {}. Please refer the attachment.

           

          Please confirm that you are calling this API before the GPIF state machine reaches the state where the counter starts. If the counter is not loaded before the counter starts you wont find it working. So you need to synchronize your firmware with the GPIF state machine if not reloading the counter.

           

           

          2) If you choose to reload the counter by passing third argument in CyU3PGpifInitCtrlCounter() as CyTrue. In this case there is no compulsion to call CyU3PGpifInitCtrlCounter() this API before reaching to the state with COUNT_CTRL. If CyU3PGpifInitCtrlCounter() API is not called before reaching the state with COUNT_CTRL, the counter will be loaded with previous limit value and start.

           

           

           

          Regards,

          Rashi

          1 of 1 people found this helpful