How to use timer of esp32?

arkayabt
Posts: 17
Joined: Fri Dec 06, 2019 6:14 am

How to use timer of esp32?

Postby arkayabt » Mon Dec 09, 2019 10:28 am

I want to build a code in which when the certain event triggers timer start counting from 0 and when this event ends it stores the total counted value of that timer in the array. And when another event get triggers timer should do the same function of counting from 0 and store that value in when the next event triggers. In the end it should store the total value in that same array. This loop gets repeat more than 100-200 times. Help me with providing code for the same.

arkayabt
Posts: 17
Joined: Fri Dec 06, 2019 6:14 am

Re: How to use timer of esp32?

Postby arkayabt » Tue Dec 10, 2019 8:19 am

How to start a hardware timer when the event begins and then just stop a timer when the event ends in esp32?

Here is the code of pic controller. Same thing i want to do in esp32. TMR1 get starts when IR_IN == 0 get detected and then this total number of pulses get store in "irdata" array and when IR_IN == 1 gets detected same of timer incrementing and storing that pulses again in array.

PIC code:

Code: Select all

 while((no_pulse < total_pulse)&& (time_over == 0))
      {
        while((IR_IN == 1) && (time_over == 0) );
        TON_bit = 0;
        TON_bit = 1;
        TMR1 = 0;
        while((IR_IN == 0)&& (time_over ==0));
         irdata[no_pulse++] = (TMR1>>8)&0xff;
         irdata[no_pulse++] = TMR1&0xff;
        TON_bit = 0;
        TON_bit = 1;
        TMR1 = 0;
        while((IR_IN == 1)&& (time_over ==0));
         irdata[no_pulse++] = (TMR1>>8)&0xff;
         irdata[no_pulse++] = TMR1&0xff;
      }

arkayabt
Posts: 17
Joined: Fri Dec 06, 2019 6:14 am

Re: How to use timer of esp32?

Postby arkayabt » Wed Dec 11, 2019 12:41 pm

Is this post answerable or not?

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: How to use timer of esp32?

Postby WiFive » Wed Dec 11, 2019 12:42 pm

Smarter to use rmt peripheral

arkayabt
Posts: 17
Joined: Fri Dec 06, 2019 6:14 am

Re: How to use timer of esp32?

Postby arkayabt » Thu Dec 12, 2019 9:00 am

Hi WiFive,
Thanks for your reply. As you have said i read README file of example. It is said that this example is only for nec protocol. I want to store signal of all remote control(of all available protocols) and produce the same on transmitter in by blaster circuit.Guide me in my above-given code.

Who is online

Users browsing this forum: CatNoir, Google [Bot] and 111 guests