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

TMS320F280049: SPIB SIMO吴信号输出

Part Number:TMS320F280049Other Parts Discussed in Thread:ADS131M06, C2000WARE

MCU SPI能输出时钟信号,SOMI能接收外部输入信号,但是SIMO无输出信号,一直为0

IO映射:

RESET :GPIO56

DRDY   :GPIO27

SCLK    :GPIO26

SOMI    :GPIO31

SIMO    :GPIO30

SPI从设备为ads131m06,不管mcu发出什么数据,SIMO上捕获到的数据总是0.

将GPIO30配置为普通IO,可以控制其高低电平。

请帮忙看看是哪里出了问题

初始化SPI代码:

void SPI_Initialize(void)
{SpibRegs.SPICCR.bit.SPISWRESET = 0;//spi reset to configuration modeSpibRegs.SPICCR.bit.CLKPOLARITY = 0;//DOut on falling Edge,Din on rising EdgeSpibRegs.SPICCR.bit.SPICHAR = (8-1);//16-bit wordSpibRegs.SPICCR.bit.SPILBK = 0;//loopback disabledSpibRegs.SPICTL.bit.MASTER_SLAVE = 1;//MasterSpibRegs.SPICTL.bit.TALK = 1;//Transmit EnableSpibRegs.SPICTL.bit.CLK_PHASE = 0;//normal clocking scheme,no delayingSpibRegs.SPICTL.bit.SPIINTENA = 0;//Interrupt DisableSpibRegs.SPIBRR.bit.SPI_BIT_RATE = SPI_BRR; //500kbpsSpibRegs.SPIPRI.bit.FREE = 1;//Halting on a breakpoint will not halt the SPIDELAY_US(10);//b15,SPIRST=1,resume FIFO to transmit or receive//b14,SPIFFENA  =1,enable FIFO//b13,TXFIFO=1,release TX FIFO from reset//b6,TXFFINTCLR =1,clear SPIFFTX[TXFFINT] flag//b4~b0,TXFFIL  =4,generate TX FIFO interrupt when there are less than 4 words in TX bufferSpibRegs.SPIFFTX.all = 0xE040;//b13,RXFIFORESET=1,re-enable RXFIFO//b6,RXFFINTCLR =1,clear SPIFFRX[RXFFINT] flag//b4-b0,RXFFIL  = F,generate RX FIFO intterupt when there are more than 15 words in RX bufferSpibRegs.SPIFFRX.all = 0x204F;//no delay between every transfer from FIFO transmit buffer to transmit shift registerSpibRegs.SPIFFCT.all = 0x0;SpibRegs.SPICCR.bit.SPISWRESET = 1;//Release the SPI from resetSPI_InitGpio();
}
//
// InitSpiGpio - Initialize SPIA GPIOs
//
void SPI_InitGpio()
{EALLOW;GpioCtrlRegs.GPAPUD.bit.GPIO30 = 0; // Enable pull-up  (SPISIMO)GpioCtrlRegs.GPAPUD.bit.GPIO31 = 0; // Enable pull-up  (SPISOMI)GpioCtrlRegs.GPAPUD.bit.GPIO26 = 0; // Enable pull-up  (SPICLK)GpioCtrlRegs.GPAPUD.bit.GPIO27 = 0; // Enable pull-up  (SPISTE)GpioCtrlRegs.GPAQSEL2.bit.GPIO30 = 3; // Asynch input  (SPISIMO)GpioCtrlRegs.GPAQSEL2.bit.GPIO31 = 3; // Asynch input  (SPISOMI)GpioCtrlRegs.GPAQSEL2.bit.GPIO26 = 3; // Asynch input  (SPICLK)GpioCtrlRegs.GPAQSEL2.bit.GPIO27 = 3; // Asynch input  (SPISTE)GpioCtrlRegs.GPAGMUX2.bit.GPIO30 = 0; //0x3GpioCtrlRegs.GPAMUX2.bit.GPIO30  = 3; //SPIB_SIMOGpioCtrlRegs.GPAGMUX2.bit.GPIO31 = 0; //0x3GpioCtrlRegs.GPAMUX2.bit.GPIO31  = 3; //SPIB_SOMIGpioCtrlRegs.GPAGMUX2.bit.GPIO26 = 1; //0x6GpioCtrlRegs.GPAMUX2.bit.GPIO26  = 2; //SPIB_CLKGpioCtrlRegs.GPAGMUX2.bit.GPIO27 = 0; //GpioCtrlRegs.GPAMUX2.bit.GPIO27  = 0; //GpioCtrlRegs.GPADIR.bit.GPIO27= 0; // InputGpioCtrlRegs.GPAPUD.bit.GPIO27= 0; // Enable pull-up /DRDYGpioCtrlRegs.GPACTRL.bit.QUALPRD3= 0x3;//6 SYSCLK cycles

	GpioCtrlRegs.GPBGMUX2.bit.GPIO56 = 0;
	GpioCtrlRegs.GPBMUX2.bit.GPIO56  = 0;GpioCtrlRegs.GPBPUD.bit.GPIO56 = 0; // Enable pull-up  (SPI /RESET)GpioCtrlRegs.GPBDIR.bit.GPIO56 = 1; // OutputGpioDataRegs.GPBSET.bit.GPIO56 = 1; // High// GpioDataRegs.GPBCLEAR.bit.GPIO56 = 1; // Low,保持复位状态//GpioCtrlRegs.GPAGMUX2.bit.GPIO30 = 0; //0//GpioCtrlRegs.GPAMUX2.bit.GPIO30  = 0; //GPIO30//GpioCtrlRegs.GPADIR.bit.GPIO30 = 1; // OutputEDIS;
}

BarBiQ:

SPI从设备是ADS131M0x,所以即便MCU发送的数据全部为0,从设备也会将此数据当成NULL_COMMAND,进行应答

,

BarBiQ:

SPI从设备是ADS131M0x,所以即便MCU发送的数据全部为0,从设备也会将此数据当成NULL_COMMAND,进行应答

以下是DSP参考手册截图

以下是通讯时逻辑分析仪截图,Master实际发送数据为3个字节(0xA0,0x00,0x00),即读取地址为0的单个寄存器

请帮忙分析一下,程序配置方面是否有问题?

,

Ben Qin:

你好,你的代码有参考TI的例程吗?你先可以使用尝试一下。

C:\ti\c2000\C2000Ware_4_03_00_00\device_support\f28004x\examples\spi

,

BarBiQ:

程序是根据spi_ex1_loopback.c来编写的,除了IO脚不同外还禁用了Loopback功能。

,

BarBiQ:

CLKPOLARITY = 0,CLK_PHASE=0:MOSI上全为低电平

CLKPOLARITY = 0,CLK_PHASE=1:MOSI上有不固定时机出现的脉冲

CLKPOLARITY = 1,CLK_PHASE=0:MOSI上全为低电平

CLKPOLARITY = 1,CLK_PHASE=1:MOSI上位置和宽度不固定的脉冲

,

BarBiQ:

原因已经找到了。

原因是将SPI设置为8位模式,发送数据时直接往SPITXBUF写入1个字节数据:

此操作实际上是往SPITXBUF的低8位写数据。

没有注意到手册上写的往SPITXBUF或SPIDAT写入数据时必须左对齐。

赞(0)
未经允许不得转载:TI中文支持网 » TMS320F280049: SPIB SIMO吴信号输出
分享到: 更多 (0)

© 2024 TI中文支持网   网站地图 鲁ICP备2022002796号-1