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.

Problem with the QPOSCNT of the EQep Module

Other Parts Discussed in Thread: TMS320F28335

Hi,

i am using the EQep modul of the TMS320F28335 on the F28335 PGF ControlCard (with the DRV8312EVM Evaluation board) for speed measurement. The Problem is, that the QPOSCNT register doesn't increment or decrement. I think the hardware is working fine, because i can see that the both GPIO pins (20 and 21) are correctly changing their values. Also the registers are correctly initialized. I tried the Example_2833xEqep_pos_speed project and it worked (QPOSCNT incremented and decremented) with the same register initialization as in my project. Also the sequence of initialization is the same as in the example project.

Here is the init code:

// Enable clock to eQEP module
    SysCtrlRegs.PCLKCR1.bit.EQEP1ENCLK = 1;

    #if (CPU_FRQ_150MHZ)
    // Unit Timer at 150 MHz SYSCLKOUT
    EQep1Regs.QUPRD = 150000000 / 100;    // 100 Hz
    #endif

    // eQEP Decoder Control Register
    EQep1Regs.QDECCTL.bit.QSRC = 00;        // QEP quadrature count mode
    EQep1Regs.QDECCTL.bit.SOEN = 0;        // Disable position-compare sync output
    EQep1Regs.QDECCTL.bit.XCR = 0;        // Count the rising/falling edge
    EQep1Regs.QDECCTL.bit.SWAP = 0;        // Quadrature-clock inputs aren't swapped
    EQep1Regs.QDECCTL.bit.QAP = 0;        // QEPA input polarity: no effect
    EQep1Regs.QDECCTL.bit.QBP = 0;        // QEPB input polarity: no effect

    // eQEP Init Position Count Register
    EQep1Regs.QPOSINIT = 0;

    // eQEP Maximum Position Count Register
    EQep1Regs.QPOSMAX = 0xffffffff;

    // eQEP Control Register
    EQep1Regs.QEPCTL.bit.FREE_SOFT = 2;    // eQEP is unaffected by emulation suspend
    EQep1Regs.QEPCTL.bit.PCRM = 00;        // QPOSCNT reset on index event
    EQep1Regs.QEPCTL.bit.UTE = 1;         // Unit Timer Enable
    EQep1Regs.QEPCTL.bit.QCLM = 1;         // Latch on unit time out
    EQep1Regs.QEPCTL.bit.SWI = 0;        // Reset SWI-Bit
    EQep1Regs.QEPCTL.bit.QPEN = 1;         // eQEP position counter is enabled

    // eQEP Capture Control Register
    EQep1Regs.QCAPCTL.bit.UPPS = 5;       // Unit position event prescaler: QCLK/32
    EQep1Regs.QCAPCTL.bit.CCPS = 7;        // Capture timer clock prescaler: SYSCLKOUT/128
    EQep1Regs.QCAPCTL.bit.CEN = 1;         // QEP Capture Enable

    //EQep1Regs.QCLR.all = 0xFFFF;

What's the mistake? Can anybody tell me what i can do to solve this problem?

  • Bernhard,

    Can you confirm that you've set up GPIO20 & GPIO21 to be QEP inputs via the GPIO mux registers as needed?

    ---

    One check that will allow you to focus on either software or hardware will be to look at the variable:
    GpioDataRegs.GPADAT.bit.GPIO20
    in the 'watch window'/'expressions' window while debugging and in real-time mode.

    It should toggle between 0 and 1 if the GPIO is receiving logical high & logical low values.  If it is toggling, then I would suspect software and would recommend looking very closely at differences between your project and the example project.


    Thank you,
    Brett

  • Hi,

    thank you for your reply. Yes i set up GPIO 20 and 21 as needed. Here is the code of the Gpio_init:

    EALLOW;

    // Enable internal pull-up for the selected pins.

        GpioCtrlRegs.GPAPUD.bit.GPIO20 = 0;   // Enable pull-up on GPIO20 (EQEP1A)
        GpioCtrlRegs.GPAPUD.bit.GPIO21 = 0;   // Enable pull-up on GPIO21 (EQEP1B)
        GpioCtrlRegs.GPAPUD.bit.GPIO22 = 0;   // Enable pull-up on GPIO22 (EQEP1S)
        GpioCtrlRegs.GPAPUD.bit.GPIO23 = 0;   // Enable pull-up on GPIO23 (EQEP1I)

        // Inputs are synchronized to SYSCLKOUT by default.

        GpioCtrlRegs.GPAQSEL2.bit.GPIO20 = 0;   // Sync to SYSCLKOUT GPIO20 (EQEP1A)
        GpioCtrlRegs.GPAQSEL2.bit.GPIO21 = 0;   // Sync to SYSCLKOUT GPIO21 (EQEP1B)
        GpioCtrlRegs.GPAQSEL2.bit.GPIO22 = 0;   // Sync to SYSCLKOUT GPIO22 (EQEP1S)
        GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 0;   // Sync to SYSCLKOUT GPIO23 (EQEP1I)

    // Configure eQEP-1 pins using GPIO regs
        GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 1;   // Configure GPIO20 as EQEP1A
        GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 1;   // Configure GPIO21 as EQEP1B
        GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 1;   // Configure GPIO22 as EQEP1S
        GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 1;   // Configure GPIO23 as EQEP1I

        EDIS;

    Also i checked the both bits in the GpioDataRegs.GPADAT register in real-time mode. They are toggling as expected. Now i am comparing my project and the example project. I implemented the initialization procedure very similar to the example project, but it doesn't work.

    Thank you,

    Bernhard

  • Bernhard,

    Thanks.  I think that looks correct.

    My recommendation might now be to look at:
    EQep1Regs.QUPRD
    to ensure that it is being set as you expect after initialization via the watch window.


    Thank you,
    Brett

  • Hi,

    the EQep1Regs.QUPRD is set as expected ( 1500000 ).

    Is there any setting in the project properties like compiler version (i use TI V6.1.0) or so that can affect the QPOSCNT.

    Is there anything to be careful about in setting the SysCtrlRegs?

    Thank you,

    Bernhard

  • Bernhard,

    One of the main thing to be aware of when writing registers is EALLOW.  Many of the most important registers are protected via EALLOW and any instructions accessing them must come after a EALLOW.  (EDIS is the inverse of EALLOW)

    Other than that I cannot think of anything to check on specifically. 

    Generic steps to follow:
    -Make sure that your code is running and not being continually reset by a watchdog or something like that
    -Make sure that you've initialized the System Clocks, PLLs, flash (if you're using it), etc appropriately
    -Make sure that the peripheral clock is on
    -Make sure that you've set the GPIOs to use your peripheral
    -Configure the peripheral correctly

    You may want to slowly move the example into your style of code and debugging to make sure things work along the way.


    Thank you,
    Brett