如题:
小弟在调试DSP中的SPI编程,将MOSI和MISO接到一起没有接从设备,收到的数据和接收的数据完全不一样,代码如下所示,
示波器接入Clock也没有波形输出。
void ancInitSpiA(void)
{
SpiaRegs.SPICCR.all=0x4F; //resume, Pol:1, 16bits
SpiaRegs.SPICTL.all=0x06; //ClkPhrase:0,Master,Talk,IntDis
SpiaRegs.SPIBRR=0x03; // LPSCLK/4
SpiaRegs.SPIFFCT.all=0; //delay 0
SpiaRegs.SPIPRI.bit.FREE=1; //free run
SpiaRegs.SPICCR.all=0x8a;
} //End
void xmit(uint16 code)
{
uint16 tempI;
uint16 data;
GpioDataRegs.GPASET.bit.GPIOA0=0;
SpiaRegs.SPICCR.bit.CLKPOLARITY=1;
SpiaRegs.SPICTL.bit.CLK_PHASE=0;
GpioDataRegs.GPACLEAR.bit.GPIOA0=1; //CsCodec=0
SpiaRegs.SPITXBUF=code;
while(!SpiaRegs.SPISTS.bit.INT_FLAG);
//tempI=SpiaRegs.SPIRXBUF; //Clear INT_FLAG
//tempI=tempI;
//while(!SpiaRegs.SPISTS.bit.INT_FLAG);
data=SpiaRegs.SPIRXBUF;
GpioDataRegs.GPASET.bit.GPIOA0=1; //Codec CS, high
} //EndGpioDataRegs.GPASET.bit.GPIOA0=1; //Codec CS, high
int main(void)
{
ancInitSysCtrlRegs();
EALLOW;
GpioMuxRegs.GPAMUX.all=0x0000;
GpioMuxRegs.GPADIR.all=0xFFF1;
//GpioA14:CsCodec; GpioA15:ibutton
//GpioA12:FmReset; GpioA11:FmCS; GpioA10:PwrOnC
EDIS;
GpioDataRegs.GPADAT.all=0xFFFF; //All to 1
//GPIOB
EALLOW;
GpioMuxRegs.GPFMUX.all = 0x1FFF; //GPIOF14-XF_PLLDIS
//GpioF13-9:Mcbsp, GpioF7-6:CanX, GpioF5-4:SCIA, GpioF3-0:SPIA
EDIS;
DINT;
ancInitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
ancInitPieVectTable();
ancInitSpiA();
xmit(0x1192);
} //End of main
谢谢大家了
|