TI中文支持网
TI专业的中文技术问题搜集分享网站

TMS320F28377S: 28377S不同引脚,不同功能的配置会有影响吗?

Part Number:TMS320F28377S

将DSP(28377S,HTQFP100封装的)的GPIO62,GPIO63,GPIO64,GPIO65设置位位eQEP3功能使用,正常,可以读到编码器数据。但是如果加上GPIO58,GPIO59,GPIO60,GPIO61设置位SPIB初始化,那么原来的eQEP3功能就无效了,读不到数据。加上SPIB程序后可以通过SPI读到数据,但是eQEP3读到的数据不对一直是0。

eQEP配置如下:

// 强制 62-65
// GpioCtrlRegs.GPBCSEL4.bit.GPIO62 = 2; // Core Select Register CPU1
GpioCtrlRegs.GPBGMUX2.bit.GPIO62 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO62 = 1; //MUX POSITION 05 (Enhanced QEP1 input A)
GpioCtrlRegs.GPBDIR.bit.GPIO62 = 0; // 1=OUTput, 0=INput
GpioCtrlRegs.GPBQSEL2.bit.GPIO62 = 2;
GpioCtrlRegs.GPBCTRL.bit.QUALPRD3 = 1;//
//
// GpioCtrlRegs.GPBCSEL4.bit.GPIO63 = 2;
GpioCtrlRegs.GPBGMUX2.bit.GPIO63 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO63 = 1;
GpioCtrlRegs.GPBDIR.bit.GPIO63 = 0; // 1=OUTput, 0=INput
GpioCtrlRegs.GPBQSEL2.bit.GPIO63 = 2;
GpioCtrlRegs.GPBCTRL.bit.QUALPRD3 = 1;
//
// GpioCtrlRegs.GPCCSEL1.bit.GPIO65 = 2;
GpioCtrlRegs.GPCGMUX1.bit.GPIO65 = 1;
GpioCtrlRegs.GPCMUX1.bit.GPIO65 = 1;
GpioCtrlRegs.GPCDIR.bit.GPIO65 = 0; // 1=OUTput, 0=INput
GpioCtrlRegs.GPCQSEL1.bit.GPIO65 = 2;
GpioCtrlRegs.GPCCTRL.bit.QUALPRD0 = 1;

EQep3Regs.QDECCTL.bit.QSRC = 0; // 00 = Quadrature count mode
EQep3Regs.QEPCTL.bit.FREE_SOFT = 3; // counters ignore debugger halt
EQep3Regs.QEPCTL.bit.PCRM = 1; // position counter reset on the maximum position
// EQep2Regs.QEPCTL.bit.PCRM = 0; // for debug reset position on index!!
// EQep2Regs.QEPCTL.bit.IEI = 3; // for debug reset position on index!!
EQep3Regs.QEPCTL.bit.IEL = 1; // z信号上升沿触发锁存
EQep3Regs.QPOSINIT = 0; // the position will be initialized to 0
EQep3Regs.QPOSMAX = 0xFFFFFFFF; // max position is the maximum possible num
EQep3Regs.QEPCTL.bit.SWI = 1; // initialize position (software init)
EQep3Regs.QEPCTL.bit.QPEN = 1; // Position counter enabled
EQep3Regs.QEPCTL.bit.SWI = 0; // clear the software init bit

SPIB配置如下:

void InitSPIB(void)
{
//
EALLOW;
// Enable the clock
CpuSysRegs.PCLKCR8.bit.SPI_B = 1; // SPI-B
//
// Configure the GPIO
//
// GPIO-60 – PIN FUNCTION = SPISIMOB
GpioCtrlRegs.GPBCSEL4.bit.GPIO60 = 0;
GpioCtrlRegs.GPBGMUX2.bit.GPIO60 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO60 = 2;
GpioCtrlRegs.GPBDIR.bit.GPIO60 = 1;

// GPIO-61 – PIN FUNCTION = SPISOMIB
GpioCtrlRegs.GPBCSEL4.bit.GPIO61 = 0;
GpioCtrlRegs.GPBGMUX2.bit.GPIO61 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO61 = 2;
GpioCtrlRegs.GPBDIR.bit.GPIO61 = 0;

// GPIO-58 – PIN FUNCTION = SPICLKB
GpioCtrlRegs.GPBCSEL4.bit.GPIO58 = 0;
GpioCtrlRegs.GPBGMUX2.bit.GPIO58 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 2;
GpioCtrlRegs.GPBDIR.bit.GPIO58 = 1;

// GPIO-59 – PIN FUNCTION = SPISTEA
GpioCtrlRegs.GPBCSEL4.bit.GPIO59 = 0;
GpioCtrlRegs.GPBGMUX2.bit.GPIO59 = 1;
GpioCtrlRegs.GPBMUX2.bit.GPIO59 = 2;
GpioCtrlRegs.GPBDIR.bit.GPIO59 = 1;

GpioDataRegs.GPBSET.bit.GPIO59 = 1; // uncomment if –> Set High initially

SpibRegs.SPICCR.all = 0x000F; //下降升沿发送,上升沿接受16位数据
SpibRegs.SPICTL.bit.MASTER_SLAVE = 1; // CPU is master
SpibRegs.SPICTL.bit.TALK = 1; // Transmit enable
SpibRegs.SPICTL.bit.CLK_PHASE = 1; // Transmit enable
SpibRegs.SPIBRR =12;//6//9; // a little bit above 10MHz
SpibRegs.SPICCR.all = 0x00CF; //自测模式
SpibRegs.SPIPRI.bit.FREE = 1; // Let the SPI continue working when the debugger stops

SpibRegs.SPIFFTX.all = 0xE044; //使能FIFO TX缓冲区位4WORD
SpibRegs.SPIFFRX.all = 0x2044; //使能FIFO RX缓冲区位4WORD
SpibRegs.SPIFFCT.all = 0x0;
EDIS;
}

Green Deng:

理论上应该没有影响,都是独立的模块。

两者都配置的情况下,两个模块的引脚输入信号都正常吗?

,

yang guo:

两个单独配置时,都正确,可以看EQep3Reg.QPOSCNT的变量读值变化和SPIB输出波形测试出来。

,

yang guo:

两者都配置的情况下,EQep3Reg.QPOSCNT的变量读值一直为0,SPIB输出波形还是正常的。

,

Green Deng:

会不会是工程中的中断配置问题,SPIB的中断频率影响了QEP模块的触发

,

yang guo:

SPIB没有用中断,是通过后台运行的。只有主程序用了一个PWM定时中断,查询QEP的计数器。

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F28377S: 28377S不同引脚,不同功能的配置会有影响吗?
分享到: 更多 (0)