2 Replies Latest reply on Nov 12, 2020 10:13 AM by KUn_4718781

    PSOC 4 USB - Interrupt

    KUn_4718781

      Hi, I have a general question about the USB component.

       

      I have developed my own demo project using AN82072 as reference.  I would like to move the functional USB bits to interrupts, but I'm not sure which interrupts to use.  For instance, I would like to make a copy of received data (OUT) just after the USB device in Automatic DMA mode is done storing the received data to SRAM(so I'm not having an access violation).  Which interrupt would should I use?

      Also, I would like to load new IN data into the IN array after the old data has been sent, and when I'm sure that the my write won't conflict with the DMA in accessing SRAM. 

      I've looked at

      USB_SOF_ISR

      USB_EP_DMA_DONE_ISR

      USB_EP_DMA_Done_isr_Start

      USB_EP_2_ISR

      etc

      I'm not sure which ISRs to use.  A benefit of this approach would be that I don't have to worry about my other code taking up too much CPU time - whenever the USB ISRs are triggered they can do their thing with high priority.

       

      I have tried putting by data handling code in USB_EP_2_ISR, which in my project is an OUT endpoint.  It processes the received data, and loads the data back into the IN buffer for echoing.  OK that's fine, but I thought that would also be a good place to use "USB_LoadEP(IN_ENDPOINT, NULL, 8);"  But the code does nothing. 

      I would think that the series of operations would be

      Packet received -> USB component(via DMA) puts data in buffer -> trips interrupt { I make copy of OUT data for processing(in this case displaying to LCD) -> I copy OUT into IN for echoing -> I use USB_LoadEP(IN, NULL, BUFFER_SIZE); }

       

      What do I do?  What interrupts do I use? 

       

      Also: can I use USB_GetEPAckState() to check if a packet has been received or transmitted properly?  I tried it and it didn't return a non zero value ever. 

        • 1. Re: PSOC 4 USB - Interrupt
          EktaN_26

          Hi,

           

          You can use the USB_EP_2_ISR for copying the data from the OUT Endpoint to the SRAM. This is because in case of OUT Endpoint this interrupt will be triggered when the host has completes communication over the particular endpoint and data is available in the endpoint buffer.

           

          I thought that would also be a good place to use "USB_LoadEP(IN_ENDPOINT, NULL, 8);"  But the code does nothing.

           

          By USB_LoadIn API do you mean USB_LoadInEP() function ? In that case why are you passing NULL for the pData parameter ?

          pData is the pointer to the buffer from which data is loaded to the IN Endpoint.

           

          I would think that the series of operations would be

          Packet received -> USB component(via DMA) puts data in buffer -> trips interrupt { I make copy of OUT data for processing(in this case displaying to LCD) -> I copy OUT into IN for echoing -> I use USB_LoadEP(IN, NULL, BUFFER_SIZE); }

           

          You can refer to the USBFS UART Code example that has a similar implementation. It uses the CDC class. In the code example data from the terminal is received in the USB OUT Endpoint and echoed back to the terminal using the IN Endpoint.

           

          In PSoC Creator go to File > Code examples > Search for USBFS UART:

          You can download the CE and have a look at the implementation.

           

          Best Regards

          Ekta

          • 2. Re: PSOC 4 USB - Interrupt
            KUn_4718781

            *By USB_LoadIn API do you mean USB_LoadInEP() function ? In that case why

            are you passing NULL for the pData parameter ?*

             

            *pData is the pointer to the buffer from which data is loaded to the IN

            Endpoint.*

             

            It is my understanding that, in the case of automatic DMA mode, that one

            uses a null parameter to trigger sending data IN(Having previously used a

            pointer to specify the buffer location).

             

            Yes - LoadINEP()

             

            On Tue, Nov 10, 2020 at 1:40 AM EktaN_26 <community-manager@cypress.com>