Hi,
I want to interfacing my TMS320F28335 with my DAC8568. It has a SPI serial communication with 3 wires, without CS.
My program has a infinite loop that send data packets from SPI pin. I have run it: With the scope I see a good square wave: SPICLK, and the transit of communication bit of SPISIMOA.
I have 2 questions:
1- Why if I increase the delay, changing the argument of delay_loop from 100 to 1000, the signals are completely distorted (so it don't works fine)?
2- My DAC accept 32 bit packets, is it correct send consequentially 2 packets of 16 bit as I do?
Thank you for helping me!
Here the source code:
#include "DSP2833x_Device.h" // DSP2833x Headerfile Include File
void InitSPI(void); // This function initializes the SPI
void InitSpiaGpio(void); // This function initializes the SPI Gpio
void delay_loop(long);
// external function prototypes
extern void InitSysCtrl(void);
extern void InitPieCtrl(void);
extern void InitPieVectTable(void);
void main(void)
{
InitSysCtrl(); // Basic Core Init from DSP2833x_SysCtrl.c
EALLOW;
SysCtrlRegs.WDCR= 0x00AF; // Re-enable the watchdog
EDIS; // 0x00AF to NOT disable the Watchdog, Prescaler = 64
DINT; // Disable all interrupts
InitPieCtrl(); // basic setup of PIE table; from DSP2833x_PieCtrl.c
InitPieVectTable(); // default ISR's in PIE
InitSpiaGpio();
InitSPI();
EINT; // Enable Interrupt (all)
ERTM; // enable realtime debug mask (DBGM)
while(1)
{
SpiaRegs.SPITXBUF = 0x3F; // command
SpiaRegs.SPITXBUF = 0x3E80; // data
delay_loop(100);
}
}
void InitSPI(void)
{
SpiaRegs.SPICCR.all =0x000F; // Reset on, rising edge, 16-bit char bits
SpiaRegs.SPICTL.all =0x000E; // Enable master mode, shift phase,
// enable talk, and SPI int disabled.
SysCtrlRegs.LOSPCP.bit.LSPCLK = 5; // SYSCLKOUT / 10 = 15 MHz
SpiaRegs.SPIBRR = 99; // SPICLK = LSPCLK / (1 + 99) = 150 kHz
SpiaRegs.SPICCR.all =0x0087; // Relinquish SPI from Reset
SpiaRegs.SPIPRI.bit.FREE = 1; // Set so breakpoints don't disturb xmission
SpiaRegs.SPICCR.bit.SPISWRESET = 1; // Release the SPI from reset
}
void InitSpiaGpio(void)
{
EALLOW;
/* Configure SPI-A pins using GPIO regs*/
// This specifies which of the possible GPIO pins will be SPI functional pins.
GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 1; // Configure GPIO16 as SPISIMOA
GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 1; // Configure GPIO17 as SPISOMIA
GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 1; // Configure GPIO18 as SPICLKA
GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 1; // Configure GPIO19 as SPISTEA
EDIS;
}
void delay_loop(long end)
{
long i;
for (i = 0; i < end; i++)
{
asm(" NOP");
EALLOW;
SysCtrlRegs.WDKEY = 0x55;
SysCtrlRegs.WDKEY = 0xAA;
EDIS;
}
}



