Page 1 of 1
How to use timer of esp32?
Posted: Mon Dec 09, 2019 10:28 am
by arkayabt
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.
Re: How to use timer of esp32?
Posted: Tue Dec 10, 2019 8:19 am
by arkayabt
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;
}
Re: How to use timer of esp32?
Posted: Wed Dec 11, 2019 12:41 pm
by arkayabt
Is this post answerable or not?
Re: How to use timer of esp32?
Posted: Wed Dec 11, 2019 12:42 pm
by WiFive
Smarter to use rmt peripheral
Re: How to use timer of esp32?
Posted: Thu Dec 12, 2019 9:00 am
by arkayabt
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.