1 Reply Latest reply on Apr 15, 2020 6:16 PM by NoriakiT_91

    3 Types of LED Blinking

    JuIn_1625121

      This is sample project for CY8CKIT-041-40XX.

       

      Each time SW2 is pressed, the following three methods are switched.

       

      BLUE LED : Firmware

      GREEN LED : PWM

      RED LED : WDT w/interrupt

       

      In this project, I roughly control the functions.

      It would be interesting to control whether or not each function works and measure the current consumption.

        • 1. Re: 3 Types of LED Blinking
          NoriakiT_91

          Thank you for provide a sample project.

          I tried with my CY8CKIT-145-40XX board.  Please let me add some comments.

           

          Out of the reset, the WDT interrupt is running behind the firmware.  So, the blinking period is quite strange.  It is better to disable the WDT at the beginning of the main loop like...

           

              CySysWdtDisable();
              isr_WDT_Stop(); 
              
              for(;;)
              {
          

           

          You mentioned about current consumption.  But the firmware main loop is executing CySleep() regardless of the ledState.  It is recommend to stop the CPU for PWM and WDT states.

           

                  /* Place your application code here. */
                  if (ledState == FW) {
                      BLUE_LED_Write(~(BLUE_LED_Read()));
                      CyDelay(1000);
                  } else if (ledState == PWM) {
                      CySysPmSleep();
                  } else {
                      CySysPmDeepSleep();
                  }
          

           

          I don't think this is a best solution.  It is better to write all control logics in the main lop not in the ISR.

           

          Regards,

          Noriaki