4 Replies Latest reply on Dec 28, 2016 5:19 AM by aditya.tiwari

    USB UART Interrupt

    user_77989180

       Hi everyone,

         

      I am using a PSOC5LP with USBUART to send data by hyperterminal.

         

      My problem is that I can find any interrupt when I press key on hyperterminal.

         

      I would like to interrupt my loop while(1) when a data is send by hyperterminal to USBUART;

         

      How can I do?

         

      I saw on the exemple USBUART they use this, but it doesn't work for what I need:

         

      if(USBUART_1_DataIsReady() != 0u)               /* Check for input data from PC */

         

              {   

         

                  count = USBUART_1_GetAll(buffer);           /* Read received data and re-enable OUT endpoint */

         

                  if(count != 0u)

         

                  {

         

                      while(USBUART_1_CDCIsReady() == 0u);    /* Wait till component is ready to send more data to the PC */ 

         

                      USBUART_1_PutData(buffer, count);     nt == BUFFER_LEN)

         

                      {

         

                          while(USBUART_1_CDCIsReady() == 0u); /* Wait till component is ready to send more data to the PC */ 

         

                          USBUART_1_PutData(NULL, 0u);         /* Send zero-length packet to PC */

         

                      }

         

                  }

         

              }  

         

       

         

      Thank you

        • 1. Re: USB UART Interrupt
          hima

           Hello Alex,

             

           

             

          There are ISR for each endpoints inside the file USBUART_episr.c. You can add your code in the OUT EP. When host is sending data to device OUT EP ISR will be triggered.

             

           

             

          Thanks,

             

          Hima

          • 2. Re: USB UART Interrupt
            user_77989180

             Perfect, thank you very much

            • 3. Re: USB UART Interrupt
              kenny.millar

              At the end of the day, all your interrupt could do is stuff the data into a buffer and set a flag that there is something in the buffer.

                 

              Then, your main loop would need to periodically check the flag, and then process the buffer contents if the flag is set.

                 

              The copy-to-buffer is already done for you, and you can consider the call to USBUART_1_DataIsReady() as the same thing as checking your flag. So why doen't the approach you pasted above work for you? I can't think of any other way to do it.

                 

              You certainly should not be processing the contents of the received data inside the interrupt service routine. 

              • 4. Re: USB UART Interrupt
                aditya.tiwari

                Hi alex934, I am facing the same problem as you faced .I too want to interrupt my while(1) loop. can you please share the solution with me beacuse i don't know how to use interrupts given in episr.c. Now i Know how to use ISR but it is transmitting and receiving only 64 bytes at a time. I wish to send 512 bytes at a time. plz give some solution