Sign in

username:

password:



Not a member?

Search c28x



Search tips

Subscribe to c28x





Discussion Groups

Discussion Groups | TMS320C28x | f2812 dsp SPI query initialization correct or not

Technical discussions about the TI C28x DSPs (including the C2810, C2811, C2812, F2801, F2806, F2808, F2810,, F2811, F2812, R2811 and R2812).

  

Post a new Thread

f2812 dsp SPI query initialization correct or not - Pari...@uwe.ac.uk - Dec 21 8:01:00 2005



hello
i have problems with the spi of f2812. please advice if you have got any programs which i can look at. I am new to dsp programming and the program which i created doesnt work for motor control applications. I am trying to send a digital value to the d to a converter thrugh the SPI.

please help
regards
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File

void spi_fifo_init(void);
void spi_xmit(Uint16 a);

int des,p;
Uint16 sdata;
Uint16 PORTA;
int x=0;

main()
{
InitSysCtrl();

DINT;
IER = 0x0000;
IFR = 0x0000;

InitPieCtrl();
EALLOW;
GpioMuxRegs.GPAMUX.all=0X0000;
GpioMuxRegs.GPADIR.all=0XF000;
GpioMuxRegs.GPBMUX.all=0X0000;
GpioMuxRegs.GPBDIR.all=0X001E;
EDIS;
EALLOW;
GpioDataRegs.GPBDAT.all= 0X000;
EDIS;

EALLOW;
GpioMuxRegs.GPFMUX.all=0x000F; // Select GPIOs to be SPI pins
// Port F MUX - x000 0000 0000 1111
EDIS;

spi_fifo_init(); // Initialize the SPI only for(;;)
{
// read
GpioDataRegs.GPBDAT.bit.GPIOB0=0;// Strobe low indicates reading data
GpioDataRegs.GPADAT.all= PORTA;
GpioDataRegs.GPBDAT.bit.GPIOB0=1;// Strobe high

if(PORTA<4096)
{
goto first;
}
else
x++;
{
first: if(x!=des)
{
spi_xmit(sdata);// transmit data
}
else
printf("ESTOPO");
}
}

}
void spi_fifo_init()
{
// Initialize SPI FIFO registers
SpiaRegs.SPICCR.bit.SPISWRESET=0; // Reset SCI

SpiaRegs.SPICCR.all=0x000F; //16-bit character
SpiaRegs.SPICTL.all=0x0006;
SpiaRegs.SPISTS.all=0x0000;
SpiaRegs.SPIBRR=0x0063; // Baud rate
SpiaRegs.SPIFFTX.all=0xC028; // Enable FIFO's, set TX FIFO level to 8

SpiaRegs.SPIFFCT.all=0x00;
SpiaRegs.SPIPRI.all=0x0010;

SpiaRegs.SPICCR.bit.SPISWRESET=1; // Enable SCI

SpiaRegs.SPIFFTX.bit.TXFIFO=1;

}

void spi_xmit(Uint16 a)
{
SpiaRegs.SPITXBUF=a;
}




(You need to be a member of c28x -- send a blank email to c28x-subscribe@yahoogroups.com )