This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM46 and eQEP: HALCoGen settings for rotary encoder

Other Parts Discussed in Thread: HALCOGEN

I'm using a rotary encoder (dial switch) with the eQEP module of RM46.

The encoder has A and B 90° phase shifted, and the contacts are hardware debounced.

I started from he HALCoGen example_eqepEdgeCapture.c, and the code reacts on moving the encoder.

I have difficulties getting a reliable value in eqepREG1->QPOSCNT though.

I do get values in the register, but they don't really represent the number of clicks I rotate the encoder.

I'm struggling with what settings to use to get  a representation of the rotation made (left or right in the eQEP eqepREG1->QPOSCNT.

Code (almost identical to the HALCoGen example_eqepEdgeCapture.c example:

/* USER CODE BEGIN (1) */
#include "eqep.h"
#include "sys_core.h"
#include <stdio.h>
/* USER CODE END */

void main(void)
{
/* USER CODE BEGIN (3) */
	uint16 deltaT = 0U;
	float velocity = 0U;
	/* EQEP initialization based on GUI Configuration. */
	QEPInit();

	/* Enable Position Counter */
	eqepEnableCounter(eqepREG1);

	/* Enable Unit Timer. */
	eqepEnableUnitTimer(eqepREG1);

	/* Enable capture timer and capture period latch. */
	eqepEnableCapture(eqepREG1);


	while(1)
	{
		/* Status flag is set to indicate that a new value is latched in the QCPRD register. */
		if((eqepREG1->QEPSTS & 0x80U) !=0U)
		{

			printf("Count %i!\n", eqepREG1->QPOSCNT);

			/* Clear the Status flag. */
			eqepREG1->QEPSTS |= 0x80U;
		}
	}
/* USER CODE END */
}

If you've used eQEP with a rotary encoder dial, it would be great if you share your experience.