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.

CCS/TMS320F280049C: eQEP input from CLB module

Part Number: TMS320F280049C
Other Parts Discussed in Thread: LAUNCHXL-F280049C, C2000WARE

Tool/software: Code Composer Studio

Hi all,

I was trying to interface CLB with eQEP1 module in LAUNCHXL-F280049C. I would like to provide QA and QB signals for quadrature encoders from the CLB TILE1 instead of the GPIO pins.

For testing purposes I directly connected CLB inputs with outputs in syscfg tool and I have generated the sequence 00 10 11 01 with the GP register.

Under this condition at each step the eQEP1 module should increment by 1, but from the debugger I noticed that the eQEP1 position increases continuously when the input is stucked at 11 or 01.

If I use the EQEP1_A and EQEP1_B inputs with the same module configurations, everything works correctly.

I'd like to know what I'm doing wrong.

Thanking you in advance.

#include "driverlib.h"
#include "device.h"
#include "clb_config.h"
#include "clb.h"

#define USE_CLB

unsigned int Position;
unsigned long Count = 0;
unsigned int Step = 0;

void main(void)
{
    Device_init();
    Device_initGPIO();

    Interrupt_initModule();
    Interrupt_initVectorTable();

    // Config CLB

    CLB_enableCLB(CLB1_BASE);
    initTILE1(CLB1_BASE);

    CLB_configLocalInputMux(CLB1_BASE, CLB_IN0, CLB_LOCAL_IN_MUX_GLOBAL_IN);
    CLB_configLocalInputMux(CLB1_BASE, CLB_IN1, CLB_LOCAL_IN_MUX_GLOBAL_IN);

    CLB_configGlobalInputMux(CLB1_BASE, CLB_IN0, CLB_GLOBAL_IN_MUX_EPWM1_CTRDIR);
    CLB_configGlobalInputMux(CLB1_BASE, CLB_IN1, CLB_GLOBAL_IN_MUX_EPWM1_CTRDIR);

    CLB_configGPInputMux(CLB1_BASE, CLB_IN0, CLB_GP_IN_MUX_GP_REG);
    CLB_configGPInputMux(CLB1_BASE, CLB_IN1, CLB_GP_IN_MUX_GP_REG);

#ifdef USE_CLB
    CLB_setOutputMask(CLB1_BASE, 0x300, true);
    CLB_setGPREG(CLB1_BASE, 0x00);
#else
    GPIO_setPinConfig(GPIO_35_EQEP1A);
    GPIO_setPadConfig(35, GPIO_PIN_TYPE_STD);
    GPIO_setPinConfig(GPIO_37_EQEP1B);
    GPIO_setPadConfig(37, GPIO_PIN_TYPE_STD);
#endif

    // Config eQEP

    EQEP_setDecoderConfig(EQEP1_BASE, EQEP_CONFIG_QUADRATURE | EQEP_CONFIG_NO_SWAP);

    EQEP_setPositionCounterConfig(EQEP1_BASE, EQEP_POSITION_RESET_MAX_POS, 0xFFFF);

    EQEP_enableModule(EQEP1_BASE);

    while(1)
    {
        if(Count++ == 10000000)
        {
            Count = 0;
            Step = (Step + 1) % 4;
            if(Step == 0)
                CLB_setGPREG(CLB1_BASE, 0x00);
            else if(Step == 1)
                CLB_setGPREG(CLB1_BASE, 0x02);
            else if(Step == 2)
                CLB_setGPREG(CLB1_BASE, 0x03);
            else
                CLB_setGPREG(CLB1_BASE, 0x01);
        }
        Position = EQEP_getPosition(EQEP1_BASE);
    }
}

  • I'm a bit confused about your connections and what you're trying to do.

    1. QA and QB are inputs to the EQEP module. You need to use GPIO for them. You can override these inputs to come from the CLB TILE OUTPUTS instead.

    2. Are you connected CLB INPUTS to CLB OUTPUTS?

    3. You can output the CLB OUTPUTS to GPIOs to make sure that the logic is correct.

    Nima

  • Hi Nima,

    Let me to explain my goal: I have a sin/cos signals from an encoder and I used PGAs to process them. In order to keep the position (without using external components) I would use the CMPSS module to square them and then connect with eQEP module using CLB XBAR and TILE1. I have already tested this chain up to the CMPSS, outputting them on the GPIO pins using the TILE1 outputs 4/5 and OUTPUT XBAR and all works fine.

    Next step is to map them to eQEP QA and QB by overriding the eQEP1 inputs to come from the CLB TILE outputs but I noticed the strange behavior that I described. So I made a simpler example to explain the problem and I posted the question.

    To answer your questions:

    1. I need to override these inputs and I used the CLB_setOutputMask function.

    2. The CLB inputs are connected with the outputs using the syscfg tool in CCS. The tile diagram is visible in the attached figure.

    3. I have output these signals to GPIO using CLB output 4 and 5 and OUTPUT XBAR and they are correct and glitch-free.

    Thanks for supporting.

  • Okay I completely understand it now.

    You need to refer to the "CLB Output Selection" section in the TRM. To override the QA, QB, FOR EQEP 1, you need to use CLB1_BASE, NOT CLB2,3,4.

    Then you need to make sure to use the TILE OUTPUT0 and OUTPUT1. Not OUTPUT 4 and OUTPUT5.

    Then you need to override the actual QA and QB signals by using "CLB_setOutputMask" with CLB1_OUT8 and CLB1_OUT9.

    Nima

  • Hi Nima,

    I have already seen that section. In fact I used the CLB TILE1 OUTPUT0 and OUTPUT1 as you can see in the image attached at the beginning of the post.

    To override the QA and QB of eQEP1 module I used the function CLB_setOutputMask (code line 35) passing 0x0300 as argument (to override CLB1_OUT8 and CLB1_OUT9). Is it correct?

    Thanks!

  • Yes that is correct.

    Nima

  • Hi Nima,

    if the code is correct I believe there is an error in the C2000Ware libraries or in the tecnical reference manual or in the connections inside the chip.

    I've done some further tests and it seems that the signals CLB1_OUT8 and CLB1_OUT9 are connected to EQEP1_QCLK and EQEP1_QDIR instead of QA and QB. That justifies the behavior that I've described in the first post.

    I tried to use CLB1_OUT10 and CLB1_OUT11 assuming they had been exchanged but it doesn't work.

    For the moment I've solved using the tile to make my custom quadrature decoder module and using CLB1_OUT8 and CLB1_OUT9 as EQEP1_QCLK and EQEP1_QDIR. This solution seems work good!

    However if you find the problem post it, perhaps it could also help other users!

    Thanks!

  • Thank you for the solution. I will dig into the correctness of the table to see if I had made a mistake in writing the TRM table.

    Nima