Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

How to use SysTick timer to count ticks from a rotary encoder? #153

Copy link
Copy link
Open
@samehmohamed88

Description

@samehmohamed88
Issue body actions

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

No one assigned

    Labels

    questionFurther information is requestedFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.