3 Replies Latest reply on Feb 17, 2020 9:15 PM by EktaN_26

    PSoC 5LP USB UART interrupt

    EmGa_3347101

      Hi all!

      I'm doing a simple program to show differents parameters stored in mi PSoC 5LP EEPROM (CY8CKIT-059).

      I need to show a menu in a USB UART COM port, so I'm using a USBUART block in PSoC Creator.

       

      The code is running OK, I can write text in the terminal and capture keys from keyboard.

       

      BUT, I need an interrupt to wakeup mcu from PMsleep when a key would pressed in the PC keyboard.

      I'm trying to use "Start of Frame (SOF) interrupt" included in the USBUART.

      ISR routine is called... but all the time. Even if there is no key pressed.

       

      This is my ISR routine:

       

      CY_ISR(USBIsrHandler)

      {

          USBIsr_Disable();

          LED_Write( !LED_Read() );

          CyDelay(100);

         

          USBIsr_ClearPending();

          USBIsr_Enable();  

      }

       

      My led is blinking all the time

       

      Can you help me, please?

        • 1. Re: PSoC 5LP USB UART interrupt
          EktaN_26

          Hello EmGa_3347101 ,

           

          The interrupt is being continuously called because the host issues SOF packets at a nominal rate of once every 1 ms for a full-speed bus.

          The ISR is thus being continuously called.

           

          In the case of PSoC 5LP if you send a device to Sleep mode then the device wakes up when host drives resume on the bus (i.e. when host drives the USB D Plus line from high to low). To send a USB device to device to sleep it is required that the host does not send the device anything for 3 ms. This usually happens when you place the PC in sleep mode (or hibernate).

           

          Can you please let me know how are you sending the device to sleep?

           

          Regards

          Ekta

          • 2. Re: PSoC 5LP USB UART interrupt
            EmGa_3347101

            Is it possible to detect USB D+ state changes?

            Please, tell me how. It would be very hopefull for me to know if my device is connected to an USB power charger or to a Host.

            • 3. Re: PSoC 5LP USB UART interrupt
              EktaN_26

              You can use USBFS_Dp_Read(); function to know the current state of D+ pin. You can keep a track of the function return values in order to detect if the state of D+ pin changes.

              In case of PSoC 5LP, PRT15_PS(0x400051F1) register is used to store the DP and the DM pins.

              For more details refer to the page 399 of PSoC 5LP register TRM: https://www.cypress.com/file/136211/download