Tool/software: Starterware
Hey everyone,
i 'm facing some trouble trying to use the eqep module of my beaglebone white. My goal is to print how much the encoder has rotated.
Following is a part of my code which builds successfully but when loaded to my board which is connected to a quadrature encoder, it doesn't work as expected.
// #define EQEP_QPOSCNT (0x0) #define EQEP_QPOSINIT (0x4) #define EQEP_QPOSMAX (0x8) #define EQEP_QDECCTL (0x28) #define EQEP_QEPCTL (0x2A) #define EQEP_QEINT (0x30) #define EQEP_QFLG (0x32) #define EQEP_QDECCTL_XCR (0x0800u) #define EQEP_QDECCTL_XCR_SHIFT (0x000Bu) #define EQEP_QDECCTL_QRSC_SHIFT (0x000Fu) #define EQEP_QDECCTL_QRSC (0xC000u) // HWREG(SOC_EQEP_1_REGS+EQEP_QPOSCNT) = 0x00000000; HWREG(SOC_EQEP_1_REGS+EQEP_QPOSINIT)=0x0000; HWREG(SOC_EQEP_1_REGS+EQEP_QPOSMAX) =2500000; HWREG(SOC_EQEP_1_REGS+EQEP_QDECCTL) = (HWREG(SOC_EQEP_1_REGS+EQEP_QDECCTL) & (~EQEP_QDECCTL_XCR)) | ((1 << EQEP_QDECCTL_XCR_SHIFT) & EQEP_QDECCTL_XCR); HWREG(SOC_EQEP_1_REGS+EQEP_QDECCTL) = (HWREG(SOC_EQEP_1_REGS+EQEP_QDECCTL) & (~EQEP_QDECCTL_QRSC)) | ((2 << EQEP_QDECCTL_QRSC_SHIFT) & EQEP_QDECCTL_QRSC); HWREGH(SOC_EQEP_1_REGS+EQEP_QEPCTL) = 0x1000; HWREGH(SOC_EQEP_1_REGS+EQEP_QEINT) = 0x0000; HWREGH(SOC_EQEP_1_REGS+EQEP_QFLG) = 0x0000; while(1) { current_pos = HWREG(SOC_EQEP_1_REGS+EQEP_QPOSCNT); UARTprintf("counts = %d \n", current_pos); }
The message i get printed though is counts=0 or whatever value i give to EQEP_QPOSINIT register, no matter how much the encoder has rotated...
Assuming that i have enabled all the necessary modules (such as uart, power domain, clocks, gpio module etc) and that i have done the proper pin-muxing, is something wrong with the above?
I mean, based on this code, shouldn't i get printed, the incrementation of the position counter (which is my goal)?
Does anyone have any suggestion or can point out any mistake?
Also, do i have any way to check if the eqep module is actually and properly enabled?
Please, i am desperate for some help..
Thanks in advance.