This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

28335 SPI Transmit Problems

Other Parts Discussed in Thread: TLV5617A

Hi, I'm new here so I hope I'm going about this correctly.  I have searched to see if anyone else has had a similar problem to mine and I can't seem to find it, so any help you all could offer would be greatly appreciated!

I am using the 28335 and running a timer interrupt every 20 us (I am trying to generate some sine waves to output to an audio amp).  I am using the SPI module to communicate with a DAC, but I can't seem to get it to run in real time.  Currently if I send out a single value to the DAC, then set up a breakpoint immediately following the transmit function, the program will run to the breakpoint, send that value and the DAC will properly output it as expected.  (I have set the SPIPRI bits to run the spi freely on halt).  The problem is, when I run the program at full speed the values never seem to get sent.  If I halt the prgram at any point the most recent SEND value is transmitted, but ONLY after a halt or breakpoint.  During the free running of the program the DAC stays frozen at whatever previous value was given to it at the previous program halt.


I know the DAC is working, or it wouldn't update at all.  I've tried sending it a simple square wave, but still no luck there.  The amp is working fine, because there is a very audible 'pop' whenever the program is halted and the output jumps.  I have checked, double checked and triple checked that the spi baud rate is slow enough for the DAC (it's an LTC1661 if that helps), and it is.

I'm really not sure what I'm doing wrong.  Any suggestions?  Here is the relevant code:

 

(main program timer interrupt loop)

{

<stuff here>

send = (send | 0x9000);

    SpiaRegs.SPIFFTX.bit.TXFFINTCLR =1; //do I need this?  It doesn't seem to affect anything since I don't actually need to read in any data
     // Transmit data
   spi_xmit(send);

}

void spi_init()
{   
    EALLOW; //not sure if I actually need this, but just in case
    SpiaRegs.SPICCR.all =0x000F;                 // Reset on, rising edge, 16-bit char bits 
    SpiaRegs.SPICTL.all =0x000E;                 // Enable master mode, delay phase of clk
                                                 // enable talk, and SPI int disabled.
    SpiaRegs.SPIBRR =0x004F;                    //originally at 0x007F   ,slowed for DAC            
    SpiaRegs.SPICCR.all =0x009F;                 // Relinquish SPI from Reset  
    SpiaRegs.SPIPRI.bit.FREE = 1;                // Set so breakpoints don't disturb xmission
//        SpiaRegs.SPIPRI.bit.SOFT = 1;
        EDIS;
}

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

void spi_fifo_init()                                       
{
// Initialize SPI FIFO registers
EALLOW;
    SpiaRegs.SPIFFTX.all=0xE040; 
    SpiaRegs.SPIFFRX.all=0x204f;
    SpiaRegs.SPIFFCT.all=0x0;
EDIS;
}

 

Thanks in advance everyone!

Jon

  • Jonathan,

    big mistake: You should have used a Texas Instruments - DAC and not a LT!

    Seriously: I cannot see a chip select signal activated / deactivated in your code. The Linear Technologies data sheet, page 6, states (compare also the timing diagram at page 5):

    "CS/LD (Pin 1):

    Serial Interface Chip Select/Load Input. When CS/LD is low, SCK is enabled for shifting data on DIN into the register. When CS/LD is pulled high, SCK is

    disabled and the operation(s) specified in the Control code, A3-A0, is (are) performed. CMOS and TTL compatible."

    Obvioulsly the DAC expects a rising edge on CS to accept the data. This is common for most SPI devices.

    Hope this helps.

    PS: If you like I can post an working example for an SPI - DAC TLV5617A.

     

     

  • Hi Jonathan,

    In the spi_init() part, you are enabling SPI loop back mode i.e. SpiaRegs.SPICCR.all =0x009F.

    Loopback mode is used for self test. Try disabling it.

     

    Regards,

    Mangala

  • Frank- sorry, I forgot to include this part.  I use this to set up the GP pins for SPI.  From my understanding both the SPI module on the DSP as well as the DAC use CS/SPISTEA as active low.    If this weren't the case then the DAC shouldn't be doing anything, correct?  Or am I misunderstanding something here?

     

    void InitSpiaGpio()
    {

       EALLOW;
    /* Enable internal pull-up for the selected pins */

        GpioCtrlRegs.GPAPUD.bit.GPIO16 = 0;   // Enable pull-up on GPIO16 (SPISIMOA)
        GpioCtrlRegs.GPAPUD.bit.GPIO17 = 0;   // Enable pull-up on GPIO17 (SPISOMIA)
        GpioCtrlRegs.GPAPUD.bit.GPIO18 = 0;   // Enable pull-up on GPIO18 (SPICLKA)
        GpioCtrlRegs.GPAPUD.bit.GPIO19 = 0;   // Enable pull-up on GPIO19 (SPISTEA)


        GpioCtrlRegs.GPAQSEL2.bit.GPIO16 = 3; // Asynch input GPIO16 (SPISIMOA)
        GpioCtrlRegs.GPAQSEL2.bit.GPIO17 = 3; // Asynch input GPIO17 (SPISOMIA)
        GpioCtrlRegs.GPAQSEL2.bit.GPIO18 = 3; // Asynch input GPIO18 (SPICLKA)
        GpioCtrlRegs.GPAQSEL2.bit.GPIO19 = 3; // Asynch input GPIO19 (SPISTEA)


       
    /* 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;
    }

     

    Mangala- I will try disabling that loopback feature.  I didn't quite understand how that should effect the output, but it's certainly worth a shot.  Doesn't it just internally connect the rx line to the tx line for testing purposes?

    Thanks for the quick replies, guys!  I'll see what happens...

     

    Jon