// Quad Encoder stuff | |
// enable the quadrature encode peripheral and peripherial clock | |
SC->PCONP |=0x00040000; // bit 18 of PCONP set to 1 | |
SC->PCLKSEL1 |=0x00000001; /* bits 1,0 00 CCLK/4 | |
01 CCLK | |
10 CCLK/2 | |
11 CCLK/8 */ | |
// Enable pins for QEI MCI0, MCI1 (PhA PhB, signals respectively) | |
PINCON->PINSEL3 = ((PINSEL3 &=0xFFFF3DFF) |= 0x00004100); /* 01 in bits 9:8 and 15:14*/ | |
//PINCON->PINSEL3 = ((PINSEL3 &=0xFFFCFFFF) |= 0x00010000); /* Turns on MCI2 index input 17:16 = 01*/ | |
// Specify Quadriture phase mode | |
// QEI->QEICON &= 0xFFFFFFFE; /* Clears position counter */ | |
QEI->QEICONF &= 0XFFFFFFFD; /* Sets bit 1 to 0, Signal mode to Quad Phase */ | |
// QEI->QEICON |= 0X00000002; /* Bit 2 to 1 counts both PhA and PhB for higher resolution */ | |
// QEI->FILTER = ****Whatever Sampling size we want*** /* Sets the number of consecutive pulses for a change in direction, etc to accepted */ | |
// Set Various Attributes | |
// QEI->QEIMAXPOS = *****insert max position*****; | |
/* Note: QEI->QEIPOS is a read only section that stores the current position */ |