Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

3 Types of LED Blinking

JuIn_1625121
Level 5
Level 5
100 sign-ins First solution authored 100 replies posted

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.

0 Likes
1 Reply
NoriakiT_91
Employee
Employee
100 likes received 50 likes received 25 likes received

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

0 Likes