Open
Description
I have seen a couple of examples that use the SysTick timer to count the rotations on a rotary encoder, like this example for the blue pill .
I was able to port that example to ESP32 (based on ESP32-Arduino code) as:
static void IRAM_ATTR pcnt_example_intr_handler(void *arg) {
uint32_t intr_status = PCNT.int_st.val;
int i = 0;
for (i = 0; i < PCNT_UNIT_MAX; i++) {
if (intr_status & (BIT(i))) {
/* Save the PCNT event type that caused an interrupt
to pass it to the main program */
int64_t status=0;
if(PCNT.status_unit[i].COUNTER_H_LIM){
status = r_enc_config.counter_h_lim;
}
if(PCNT.status_unit[i].COUNTER_L_LIM){
status = r_enc_config.counter_l_lim;
}
//pcnt_counter_clear(ptr->unit);
PCNT.int_clr.val = BIT(i); // clear the interrupt
count = status + count;
}
}
}
I saw there's a systick timer in this repo and a flash example based on it, but I can't reason around how I would use it for the rotary encoder.
Any help with this would be highly appreciated!
Metadata
Metadata
Assignees
Labels
Further information is requestedFurther information is requested