5 Replies Latest reply on Oct 29, 2018 9:00 PM by anks

    USBUART_episr.c: Calling callback upon interrupt

    veredz_2582751

      Hello,

       

      In the sample USBFS_UART01 sample, one of the automatically generated sources is:

      USBUART_episr.c

       

      I want that my callback will be called upon an interrupt.

      Should I modify USBUART_episr.c ?

       

      I also added:

      USBUART_EnableSofInt (); to main.c right after:

      USBUART_Start

       

      In general, how can I connect a specified interrupt in a device to my code ?

       

      Thank you,

      Zvika

        • 1. Re: USBUART_episr.c: Calling callback upon interrupt
          veredz_2582751

          Hello,

           

          Following is a fragment of the generated source.

          Should I call my code (e.g giving a semaphore)  between the bold lines ?

           

          Thank you,

          Zvika

           

          .....

          #if (USBUART_SOF_ISR_ACTIVE)

              /*******************************************************************************

              * Function Name: USBUART_SOF_ISR

              ****************************************************************************//**

              *

              *  Start of Frame Interrupt Service Routine.

              *

              *

              *******************************************************************************/

              CY_ISR(USBUART_SOF_ISR)

              {

              #ifdef USBUART_SOF_ISR_ENTRY_CALLBACK

                  USBUART_SOF_ISR_EntryCallback();

              #endif /* (USBUART_SOF_ISR_ENTRY_CALLBACK) */

           

           

                 /* `#START SOF_USER_CODE` Place your code here */

                  /* `#END` */

           

           

                  USBUART_ClearSieInterruptSource(USBUART_INTR_SIE_SOF_INTR);

           

           

              #ifdef USBUART_SOF_ISR_EXIT_CALLBACK

                  USBUART_SOF_ISR_ExitCallback();

              #endif /* (USBUART_SOF_ISR_EXIT_CALLBACK) */

              }

          #endif /* (USBUART_SOF_ISR_ACTIVE) */

          • 2. Re: USBUART_episr.c: Calling callback upon interrupt
            user_78878863

            You can do that, but then your changes are lost on a clean build.

            Better is to use

            USBUART_StartEx(&YourISR);

            in your main function (with your ISR routine defined with CY_ISR).

            • 3. Re: USBUART_episr.c: Calling callback upon interrupt
              veredz_2582751

              Hello,

               

              Thank you for your reply.

               

              In USBUART.h there is no declaration for USBUART_StartEx (...)

              I tried to call this routine but got a link error.

              I'm using Creator 4.0

               

              Best regards,

              Zvika

              • 4. Re: USBUART_episr.c: Calling callback upon interrupt
                veredz_2582751

                Hello,

                 

                 

                Thank yo very much for your reply !

                 

                 

                I'v noticed that the SOF ISR is called a lot (>1000) even if not a single character is sent from PC to the PSOC.

                 

                Can you tell why ?

                 

                 

                I want to trigger a task (e.g with Semaphore) upon one or more characters sent to PSOC.

                 

                 

                Thank you,

                 

                Zvika

                • 5. Re: USBUART_episr.c: Calling callback upon interrupt
                  anks

                  Hi,

                   

                  Even when there is no active data transmission, the host uses Start of Frame (SOF) tokens to keep devices out of a suspend state.

                  In the ISR of particular EP you can use API "USBFS_GetEPCount()" which returns the current byte count from the specified USBFS endpoint.

                  It is dependent on your firmware that you write in callback.