Part Number: TMS320F28335
Tool/software: Code Composer Studio
Dear Sir/Madam,
I am using the function SPI on F28335. I want to interface the F28335 with another board AD9834, which supports 3 wire SPI. I want the F28335 to continuously output five array of control word to AD9834, and the control word will be read on the falling edge of the SPI CLOCK into AD9834's registers. But right now I have no ouput on the pins MOSI and SPICLK, which are GPIO16 and GPIO18, here are my codes in the main file, can you please help me with this pronlem? I think the problems may lies in the condition of "if", but I don't know how to write correct code. What's more, I only want these control words to be output once. Thanks a lot!
Best,
Jiangwei
#include "DSP28x_Project.h"
void spi_fifo_init(void);
void spi_init(void);
//void error(void);
void delay_loop(void);
void main(void)
{
Uint16 control0;
Uint16 freq0_lsb;
Uint16 freq0_msb;
AN-1070.pdfUint16 phase;
Uint16 reset;
InitSysCtrl();
InitSpiaGpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
spi_fifo_init(); // Initialize the Spi FIFO
spi_init();
control0=0x2100;
freq0_lsb=0x50C7;
freq0_msb=0x4000;
phase=0xC000;
reset=0x2000;
SpiaRegs.SPITXBUF=control0;
if(SpiaRegs.SPISTS.bit.INT_FLAG == 1)
SpiaRegs.SPITXBUF=freq0_lsb;
if(SpiaRegs.SPISTS.bit.INT_FLAG == 1)
SpiaRegs.SPITXBUF=freq0_msb;
if(SpiaRegs.SPISTS.bit.INT_FLAG == 1)
SpiaRegs.SPITXBUF=phase;
if(SpiaRegs.SPISTS.bit.INT_FLAG == 1)
SpiaRegs.SPITXBUF=reset;
}
void delay_loop()
{
long i;
for (i = 0; i < 1000000; i++) {}
}
void spi_fifo_init()
{
// Initialize SPI FIFO registers
SpiaRegs.SPIFFTX.all=0xE040;
SpiaRegs.SPIFFRX.all=0x204f;
SpiaRegs.SPIFFCT.all=0x0;
}
void spi_init()
{
SpiaRegs.SPICCR.all =0x004F; // Reset on, FALLing edge, 16-bit char bits
SpiaRegs.SPICTL.all =0x0006; // Enable master mode, normal phase,
// enable talk, and SPI int disabled.
SpiaRegs.SPIBRR =0x0063;
SpiaRegs.SPICCR.all =0x00CF; // Relinquish SPI from Reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
}