cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 5, 3 & 1 MCU

New Contributor

 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

0 Likes
Reply
4 Replies
Employee

 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

0 Likes
Reply
New Contributor

 Perfect, thank you very much

0 Likes
Reply
Anonymous
Not applicable

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

0 Likes
Reply
New Contributor II

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. 

0 Likes
Reply