USBUART_episr.c: Calling callback upon interrupt

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

cross mob
ZvVe_2582751
Level 1
Level 1
5 replies posted Welcome! 5 questions asked

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

0 Likes
1 Solution

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.

View solution in original post

0 Likes
5 Replies
ZvVe_2582751
Level 1
Level 1
5 replies posted Welcome! 5 questions asked

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) */

0 Likes

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).

0 Likes

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

0 Likes

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

0 Likes

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.

0 Likes