Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新SDK无法使用软件定时器,无法执行回调函数,os_timer_arm()? (GIT8266O-342) #778

Open
xuhongv opened this issue Dec 11, 2019 · 0 comments
Assignees

Comments

@xuhongv
Copy link

xuhongv commented Dec 11, 2019

环境

  • IDF version: v3.2-264-g6665b4de-dirty
  • Development Env: Make
  • Power Supply: external 5V

问题描述

无法使用软件定时器?回调函数不执行!!!!

代码

//定时器
os_timer_t os_timer;

#define PWM_PERIOD (100)
static const char *TAG = "pwm_example";

// pwm pin number
const uint32_t pin_num[2] = {
    14,
    12};

// duties table, real_duty = duties[x]/PERIOD
uint32_t duties[2] = {
    0,
    0,
};

// phase table, delay = (phase[x]/360)*PERIOD
int16_t phase[4] = {
    0,
    0,
};

static int set_duty = 10;
static bool dir = true;
void Task_pwm_blank(void *arg)
{
    printf("dss");
    if (dir == true)
    {
        if (++set_duty >= 100)
        {
            dir = false;
        }
    }
    else
    {
        if (--set_duty <= 5)
        {
            dir = true;
        }
    }

    pwm_set_duty(0, set_duty);
    pwm_set_duty(1, set_duty);
    pwm_start();
}

/******************************************************************************
 * FunctionName : app_main
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void app_main(void)
{
    //Initialize NVS
    esp_err_t ret = nvs_flash_init();
    if (ret == ESP_ERR_NVS_NO_FREE_PAGES)
    {
        ESP_ERROR_CHECK(nvs_flash_erase());
        ret = nvs_flash_init();
    }
    ESP_ERROR_CHECK(ret);

    pwm_init(PWM_PERIOD, duties, 2, pin_num);
    pwm_set_phases(phase);

    os_timer_disarm(&os_timer);
    os_timer_setfn(&os_timer, (os_timer_func_t *)(Task_pwm_blank), NULL);
    os_timer_arm(&os_timer, 6, 1);
}

日志

MAC address from EFUSE
phy_version: 1155.0, 6cb3053, Nov 11 2019, 17:31:08, RTOS new
I (337) phy_init: phy ver: 1155_0
I (340) reset_reason: RTC reset 2 wakeup 0 store 124852705, reason is 2
SDK version:v3.2-264-g6665b4de-dirty
esp_get_free_heap_size : 101864  
esp_get_minimum_free_heap_size : 99544  
system_get_flash_size_map(): 2 
I (381) gpio: GPIO[12]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (395) gpio: GPIO[14]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 
I (409) pwm: --- PWM v3.2
@github-actions github-actions bot changed the title 新SDK无法使用软件定时器,无法执行回调函数,os_timer_arm()? 新SDK无法使用软件定时器,无法执行回调函数,os_timer_arm()? (GIT8266O-342) Dec 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants