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

USB EZ-PD™ Type-C Forum Discussions

Kok
Level 2
Level 2
5 questions asked 5 replies posted 10 sign-ins

Hello,

I have an Led that controls brightness through PWM, and a button that controls PWM working, but the PWM only works at begining.

res.pngp1.pngp2.png

led.png

 

#define LED_BLINK_TIMER_ID (0xC6)
#define LED_BLINK_PERIOD   (5000)

#define LED_W_ON() \
    do { \
        PWM_1_Stop(); \
        PWM_1_WritePeriod(5000); \
        PWM_1_WriteCompare(1000); \
        PWM_1_WriteCounter(0); \
        PWM_1_Enable(); \
    }while(0)
    
#define LED_W_OFF() \
    do { \
        PWM_1_Stop(); \
    }while(0)

void led_module_init(void)
{
    PWM_1_Start();
    PWM_1_Stop();
}
static void led_blink_handle(uint8_t port, timer_id_t id)
{
    (void)port;
    (void)id;
    
    timer_stop(0, LED_BLINK_TIMER_ID);
    LED_W_OFF();
}

void btn_press_detect(void)
{
    if (btn_get_press_short())
    {
        LED_W_ON();
        timer_start(0, LED_BLINK_TIMER_ID, LED_BLINK_PERIOD, led_blink_handle);
    }
}

void app_main_loop(void)
{
    btn_press_detect();
    //CyDelay(50);
}

When I first press the button, the led blinks for about 3 seconds and then goes off. When I press the button again, the led goes off, If I add CyDelay(50) to the app_main_loop function, it will always work.

Please help to see what is going on. In addition, serial port, I2C and other GPIO resources are used in the project. Looking forward to your reply!

0 Likes
1 Solution
Kok
Level 2
Level 2
5 questions asked 5 replies posted 10 sign-ins

Ok, this problem is really caused by system deep sleep. Your solution works good. Thank you!

View solution in original post

0 Likes
3 Replies
Kok
Level 2
Level 2
5 questions asked 5 replies posted 10 sign-ins

The platform used is EZ-PD 5225 and the debugger is Miniprog4

0 Likes
ShifangZ_26
Moderator
Moderator
Moderator
10 likes given 250 sign-ins 1000 replies posted

Hello Kok,

1. Could you please kindly disable deep sleep in the firmware and let CCG5 firmware do not enter deep sleep mode?

2. If you could like to register PWM status in deep sleep and let CCG5 firmware do not enter deep sleep mode if the PWM is working. Below API recommend you take a look. 

bool system_sleep(void) 

And, adding concerns flag of PWM in this function.

 

Best Regards,

Lisa

0 Likes
Kok
Level 2
Level 2
5 questions asked 5 replies posted 10 sign-ins

Ok, this problem is really caused by system deep sleep. Your solution works good. Thank you!

0 Likes