不知道是不是SPI寄存器配置的有问题,求指教
void SPIA_Init(void){
EALLOW;
GpioCtrlRegs.GPBPUD.bit.GPIO54 = 0; // Enable pull-up on GPIO54 (SPISIMO)
GpioCtrlRegs.GPBQSEL2.bit.GPIO54 = 3; // Asynch input GPIO54 (SPISIMO)
GpioCtrlRegs.GPBMUX2.bit.GPIO54 = 1; // Configure GPIO54 as SPISIMO
GpioCtrlRegs.GPBDIR.bit.GPIO54 = 1; // Configure GPIO54 as Output pin
GpioCtrlRegs.GPBPUD.bit.GPIO55 = 0; // Enable pull-up on GPIO55 (SPISOMI)
GpioCtrlRegs.GPBQSEL2.bit.GPIO55 = 3; // Asynch input GPIO55 (SPISOMI)
GpioCtrlRegs.GPBMUX2.bit.GPIO55 = 1; // Configure GPIO55 as SPISOMI
GpioCtrlRegs.GPBDIR.bit.GPIO55 = 0; // Configure GPIO54 as Input pin
GpioCtrlRegs.GPBPUD.bit.GPIO56 = 0; // Enable pull-up on GPIO56 (***)
GpioCtrlRegs.GPBQSEL2.bit.GPIO56 = 3; // Asynch input GPIO56 (***)
GpioCtrlRegs.GPBMUX2.bit.GPIO56 = 1; // Configure GPIO56 as ***
GpioCtrlRegs.GPBDIR.bit.GPIO56 = 1; // Configure GPIO56 as Output pin
// GpioDataRegs.GPBCLEAR.bit.GPIO56 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO57 = 0; // Enable pull-up on GPIO57 (SPISET)
GpioCtrlRegs.GPBQSEL2.bit.GPIO57 = 3; // Asynch input GPIO57 (SPISET)
GpioCtrlRegs.GPBMUX2.bit.GPIO57 = 1; // Configure GPIO57 as SPISET
GpioCtrlRegs.GPBDIR.bit.GPIO57 = 1; // Configure GPIO57 as Output pin
GpioDataRegs.GPBCLEAR.bit.GPIO57 = 1;
GpioCtrlRegs.GPBPUD.bit.GPIO58 = 0; // Enable pull-up on GPIO58
GpioCtrlRegs.GPBMUX2.bit.GPIO58 = 0; // Configure GPIO58 as I/O
// GpioCtrlRegs.GPBDIR.bit.GPIO58 = 1; // Configure GPIO58 as Output pin
GpioDataRegs.GPBSET.bit.GPIO58 = 1;
EDIS;
EALLOW;
SysCtrlRegs.PCLKCR3.bit.GPIOINENCLK = 1;
SysCtrlRegs.PCLKCR0.bit.SPIAENCLK = 1; //SPI-A
EDIS;
// InitSpiaGpio();
//Initialize SPI FIFO registers
SpiaRegs.SPIFFTX.all = 0xE040; // Enable FIFO, clear transmition interrupt
SpiaRegs.SPIFFRX.all = 0x204F; // Enable FIFO to receive 16th depth
SpiaRegs.SPIFFCT.all = 0x0; // Clear FIFO counter
SpiaRegs.***.bit.SPISWRESET = 0; // Reset on
SpiaRegs.***.all = 0x0007; // 8-bit, send on rising edge, no loopback
SpiaRegs.***.all = 0x0006; // No phase delay, main mode
SpiaRegs.SPIBRR = 0x007F;
SpiaRegs.***.all = 0x0087; // NO Self-test mode and release reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Free running
SpiaRegs.***.bit.SPISWRESET = 1; // SPI software reset
}
Uint8 SPIA_SendRecData(Uint16 dat){
SpiaRegs.SPITXBUF = (dat << 8); //Transmit data
// while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG == 1);
while(SpiaRegs.SPIFFRX.bit.RXFFST != 1);
return ((SpiaRegs.SPIRXBUF)); // Recieve data
}
Green Deng:
你好,能详细描述一下你的问题吗?特别是硬件上是否有测试过?你配置的引脚有对应的信号输入输出吗?
如果不确定的话可以先用例程测试一下硬件通讯:C:\ti\c2000\C2000Ware_3_02_00_00\device_support\f2833x\examples\spi_loopback
DLAM:
回复 Green Deng:
感谢您的答复。自测没有成功,我现在觉得是CMD的配置或者是DSP2833x_CodeStartBranch.asm有问题,但是现在没有头绪。
Green Deng:
回复 DLAM:
你好,你是用例程自测的没有成功吗?