Rhab 1 Posted September 2, 2015 Share Posted September 2, 2015 Hi, i'm trying tu use a qei too, but i always get errors like error: 'GPIO_PD6_PHA0' was not declared in this scope also with the code-example above... can someone tell me what i'am doing wrong? i think GPIO_PD6_PHA0 is declared in pin_map.h ... i am using EK-TM4C123GXL Quote Link to post Share on other sites
Rhab 1 Posted September 2, 2015 Share Posted September 2, 2015 ok if i use GPIOPinConfigure(0x00031806); // 0x00031806 =>GPIO_PD6_PHA0 GPIOPinConfigure(0x00031C06); // 0x00031C06 => GPIO_PD7_PHB0 it works... But is there any possibility to use automapping? Quote Link to post Share on other sites
StrangerM 25 Posted March 8, 2017 Share Posted March 8, 2017 I have played with QEI. I have two quadrature encoders with index. But where they are? FR4133 was close . And I have made the simple emulator of encoder with index.I have connected FR4133 with Tiva. P1.3->PD3+PE1 (INDEX&Interrupt) ; P1.4->PD7 (PhB) ; P1.5->PD6 (PhA)The code from here and from http://forum.43oh.com/topic/8875-problems-using-qei-with-ek-tm4c123gxl/ was used for Tiva program. #include <stdint.h> #include <stdbool.h> #include "inc/hw_gpio.h" #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/gpio.h" #define PART_TM4C123GH6PM #include "driverlib/pin_map.h" #include "driverlib/qei.h" #include "driverlib/sysctl.h" #define I PE_1 volatile uint32_t pos1; volatile uint32_t pos_index ; volatile uint32_t vel; volatile int32_t dir; void config_QEI() { SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); //Unlock GPIOD7 // HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY; // HWREG(GPIO_PORTD_BASE + GPIO_O_CR) |= 0x80; // HWREG(GPIO_PORTD_BASE + GPIO_O_AFSEL) &= ~0x80; // HWREG(GPIO_PORTD_BASE + GPIO_O_DEN) |= 0x80; // HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = 0; // Enable QEI Peripherals SysCtlPeripheralEnable(SYSCTL_PERIPH_QEI0); //Set Pins to be PHA0 and PHB0 GPIOPinConfigure(GPIO_PD6_PHA0); //GPIOPinConfigure(0x00031806); //0x00031806 =>GPIO_PD6_PHA0 GPIOPinConfigure(GPIO_PD7_PHB0); //GPIOPinConfigure(0x00031C06); // 0x00031C06 => GPIO_PD7_PHB0 GPIOPinConfigure(GPIO_PD3_IDX0); // // GPIO_PD3_IDX0 //Set GPIO pins for QEI GPIOPinTypeQEI(GPIO_PORTD_BASE, (GPIO_PIN_3 |GPIO_PIN_6 | GPIO_PIN_7 )); // GPIOPinTypeQEI(GPIO_PORTD_BASE, (GPIO_PIN_6 | GPIO_PIN_7 )); //HWREG(GPIO_PORTD_BASE + GPIO_O_LOCK) = GPIO_LOCK_M; // Configure quadrature encoder, use an arbitrary top limit of 1000-1 and enable QEI QEIConfigure(QEI0_BASE,(QEI_CONFIG_CAPTURE_A_B | QEI_CONFIG_RESET_IDX | QEI_CONFIG_QUADRATURE | QEI_CONFIG_NO_SWAP), 999); QEIEnable(QEI0_BASE); //Set position to a middle value QEIPositionSet(QEI0_BASE,500); //Configure and enable velocity QEIVelocityConfigure(QEI0_BASE, QEI_VELDIV_1, SysCtlClockGet()/2); // Divide by clock speed to get counts/sec QEIVelocityEnable(QEI0_BASE); } void setup() { config_QEI(); pinMode(I, INPUT); Serial.begin(9600); Serial.println("Start:"); Serial.println("--------"); attachInterrupt(I, blink, RISING ); } void loop() { // detachInterrupt(I) ; Serial.print("pos_index="); Serial.println(pos_index); Serial.print("pos1="); Serial.println(pos1); Serial.print("vel=");Serial.println(vel); Serial.print("dir=");Serial.println(dir); Serial.println("--------"); delay(1000); } void blink() { vel = QEIVelocityGet(QEI0_BASE); dir = QEIDirectionGet(QEI0_BASE); pos_index = QEIPositionGet(QEI0_BASE); delayMicroseconds(400); pos1 =QEIPositionGet(QEI0_BASE); } This is the code of emulator #include <msp430.h> #include "LCD_Launchpad.h" #define M P2_6 #define M1 P1_2 #define IDX P1_3 #define PA P1_4 #define PB P1_5 int t=500 ; int n=0 ; LCD_LAUNCHPAD myLCD ; void setup() { // put your setup code here, to run once: myLCD.init(); pinMode(M, INPUT_PULLUP); pinMode(M1, INPUT_PULLUP); pinMode(IDX, OUTPUT); pinMode(PA, OUTPUT); pinMode(PB, OUTPUT); digitalWrite(PA, LOW); digitalWrite(PB, LOW); digitalWrite(IDX, LOW); Serial.begin(9600) ; myLCD.clear(); Serial.println(100); } void loop() { // put your main code here, to run repeatedly: n=n+1 ; digitalWrite(PB, HIGH) ; delayMicroseconds(t); if(n==1) {digitalWrite(IDX, LOW); } digitalWrite(PA, HIGH); delayMicroseconds(t); digitalWrite(PB, LOW); delayMicroseconds(t); digitalWrite(PA, LOW); delayMicroseconds(t); digitalWrite(PB, LOW); if(n==1000) {n=0 ; digitalWrite(IDX, HIGH); } } This is result pos_index=999pos1=4vel=6282dir=1--------pos_index=999pos1=4vel=6282dir=1--------pos_index=999pos1=4vel=6282dir=1--------...... This is useful system for studying QIE and QIE API Fmilburn 1 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.