Home > other >  ESP32 micropython underlying C language development, needs help
ESP32 micropython underlying C language development, needs help

Time:11-26

Is simply the underlying C GPIO pulled down, but the precision is demanding, pulse width is 0.5 us, stuck doing half stuck,

CodePudding user response:

Using hardware timer

CodePudding user response:

refer to the second floor worldy response:
using hardware timer

Timer_config_t config.
The config. Divider=4;//frequency division, the default clock is 80 MHZ
The config. Counter_dir=TIMER_COUNT_UP;
The config. Counter_en=TIMER_PAUSE;
The config. Alarm_en=TIMER_ALARM_EN;
The config. Intr_type=TIMER_INTR_LEVEL;
The config. Auto_reload=1;//that can automatically load
Timer_init (TIMER_GROUP_0 TIMER_0, & amp; The config);

Timer_set_counter_value (x00000000ull TIMER_GROUP_0 TIMER_0, 0);
Timer_set_alarm_value (TIMER_GROUP_0 TIMER_0, 5);
Timer_enable_intr (TIMER_GROUP_0 TIMER_0);
Timer_isr_register (TIMER_GROUP_0, TIMER_0 timer01_isr,
NULL, ESP_INTR_FLAG_IRAM, NULL);

Timer_start (TIMER_GROUP_0 TIMER_0);

Excuse me, this is a hardware timer that I can reach the limit is 3.4 us, this is why,
After reaches the limit, frequency division and timer_set_alarm_value () in the change has no effect,

CodePudding user response:

Timer01_isr processing time must be smaller than the regular time intervals, in the time interval you only 0.5 us,

CodePudding user response:

reference 4 floor worldy response:
timer01_isr processing time must be less than the time interval, in your time interval only 0.5 us,


Static int a=0;
The STATIC void IRAM_ATTR timer00_isr ()
{

A +=1;
If (a % 2==0) {
GPIO. Out_w1ts=(1 & lt; & lt; TEST).//higher level
} else {
GPIO. Out_w1tc=(1 & lt; & lt; TEST).//lower level
}

Us time interval is 0.5 I think should be able to do these things

CodePudding user response:

Should not be completed, enter the interrupt function before and after, and the scene of the implicit protection pressure and flare stack operation, should be more than 4 instruction

  • Related