Skip to content

There is a problem with the ESP32 timer, and there is no response when the program is downloaded #5544

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

Closed
mjkdz opened this issue Aug 15, 2021 · 3 comments

Comments

@mjkdz
Copy link

mjkdz commented Aug 15, 2021

There is a problem with the ESP32 timer, and there is no response when the program is downloaded

/*

  • ESP32共有4个定时器0-3。这些都是基于64位的通用定时器。
  • 每个定时器都有一个16位预分频器(2-65536)以及可以自动
  • 重新加载的 64 位递增/递减计数器
    /
    hw_timer_t
    timer = NULL;//配置定时器我们需要一个指向hw_timer_t类型变量的指针
    volatile int led=2;
    volatile byte ZT =0;//volatile关键字说明我们需要在中断中修改这个变量
    void IRAM_ATTR kaiDS(){//定时器中断函数
    ZT=!ZT;
    digitalWrite(led,ZT);
    }

void setup() {
Serial.begin(115200);
pinMode(led, OUTPUT);

//设置定时器,0是定时器(4个定时器)80预分频器的值,true上升沿计数.false下降沿计数
timer=timerBegin(0,80,true);
//Timer指针变量,kaiDS触发中断执行函数,Timer 触发器与时钟同步true上升沿时触发定时器false当时钟信号改变电平时触发定时器
timerAttachInterrupt(timer,&kaiDS,true);
//Timer指针变量,1000000触发中断频率,true每次触发后自动重置定时器中断
timerAlarmWrite(timer,1000000,true);
timerAlarmEnable(timer);//启动定时器
}
void loop() {
}

@mjkdz
Copy link
Author

mjkdz commented Aug 15, 2021

The previous version is good

@VojtechBartoska
Copy link
Contributor

@mjkdz Please can you rewrite your issue in English?

@VojtechBartoska
Copy link
Contributor

@mjkdz Do you have any update to this issue? If not, I will close it in few days.

@VojtechBartoska VojtechBartoska added the Resolution: Awaiting response Waiting for response of author label Nov 18, 2021
@VojtechBartoska VojtechBartoska removed the Resolution: Awaiting response Waiting for response of author label Dec 23, 2021
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