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);
}
}