Setup Quadrature Encoder Inputs

dsPIC33EP256MU806 example:


	//----- SETUP QEI 1 -----
	QEI1CONbits.QEIEN = 0;		//Module counters are disabled
	QEI1CONbits.CCM = 0;		//Quadrature Encoder mode
	QEI1CONbits.PIMOD = 0;		//Index input event does not affect position counter
	QEI1CONbits.IMV = 0;		//Index input event does not affect position counter
	QEI1CONbits.INTDIV = 0;
	QEI1CONbits.CNTPOL = 0;
	QEI1CONbits.GATEN = 0;

	QEI1IOCbits.QCAPEN = 0;
	QEI1IOCbits.FLTREN = 1;		//Input Pin Digital filter is enabled
	QEI1IOCbits.QFDIV = 0;		//Digital Input Filter Clock Divide Select bits <Set the digital input filter clock divide based on our osc and max encoder speed
	QEI1IOCbits.OUTFNC = 0;		//Output is disabled
	QEI1IOCbits.SWPAB = 0;
	QEI1IOCbits.HOMPOL = 0;
	QEI1IOCbits.IDXPOL = 0;
	QEI1IOCbits.QEBPOL = 0;
	QEI1IOCbits.QEAPOL = 0;

	POS1CNTH = 0;				//Write MSW first
	POS1CNTL = 0;

	QEI1CONbits.QEIEN = 1;		//Module counters are enabled

	// = POS1CNTL;				//Read LSW first
	// = POS1CNTH;




We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.


Your email address will not be published.