4 Replies Latest reply on Sep 24, 2019 10:10 PM by RashiV_61

    Find GPIF2 mirror state IDs

    KaFu_3122371

      Is there a way to know what state IDs are assigned to mirror states in the FX3's GPIF2 state machine (the value returned by CyU3PGpifGetSMState)?

        • 1. Re: Find GPIF2 mirror state IDs
          RashiV_61

          Hello,

           

          Yes, the GPIF state IDs can be read using CyU3PGpifGetSMState API.

          For using this API you can call this API as shown:

           

          uint8_t SMState =0;

          CyU3PGpifGetSMState (&SMState);

          CyU3PDebugPrint (4, "\n\rAplnStrt:SMState = 0x%x", SMState);

           

          Note: To get the state id from some callback (eg: DMA Callback) function, you can call this API in that function and set an event there(refer attachment). Then in the for{} loop track that event to get the state printed. It is recommended not to use debug prints in the call back functions.

           

          Regards,

          Rashi

          • 2. Re: Find GPIF2 mirror state IDs
            KaFu_3122371

            My problem is that I have INTR_CPU action in multiple states, and I want to be able to differentiate between the states that interrupted the CPU. However if I modify the state machine such that I can know which state interrupted the CPU in some other way, the mirror ID that I get with that modified state machine is different from the mirror ID that I get without such modification.

            • 3. Re: Find GPIF2 mirror state IDs
              RashiV_61

              Hello,

               

              Please find the attached firmware. I have registered a GPIF callback. In the call back you get the current state. You can parse the current state as per the  header file (Refer attachment).

              You assign different variables for different cases and increment them when there is a call back. I have used counter as variable for the example firmware.

               

              Please let me know if this helps

               

              Regards,

              Rashi

              • 4. Re: Find GPIF2 mirror state IDs
                RashiV_61

                Hello,

                 

                I would like to add to my previous post.

                From the source code of CyU3PGpifGetSMState() API, it is found that it accesses bits 31:24 of  GPIF_WAVEFORM_CTRL_STAT register (refer FX3 TRM Section 10)  for current state.

                When the CPU interrupt is triggered from the mirror state The 31 bit of GPIF_WAVEFORM_CTRL_STAT register is set to 1.

                 

                For example: If the CPU interrupt is in State 3 (which has mirror states)

                The current state bits [31:24] of  GPIF_WAVEFORM_CTRL_STAT would be 0x83 (128 + state no.)

                 

                 

                 

                You can call CyU3PGpifGetSMState() API in the GPIF callback and get the ID into a variable and later get it printed in the for{} loop.

                 

                Please share the GPIF state machine files (.cyfx) so that i can help you better (for the case where there are more one mirror state  of that state)

                 

                Regards,

                Rashi