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.

TMS320C6455 DSK (Setting up McBSP to SPI slave)

Hello! 

We are working on a school project, where we need to set up a SPI connection between NXP Mbed module and this DSP development kit. The DSP should be a slave. We have successfully set up SPI connection between two Mbed kits, so the Mbed should be correctly configured. 

We would like to use EDMA Transfer or DMA Transfer. 

Our connections:

MBED DSP (J3 peripheral expansion connector)
SCLK     ----           Pin 27 (CLKR0)
MOSI ---- Pin 30 (DR0)
MISO ---- Pin 24 (DX0)
CS ---- Pin 29 (FSR0)

We have tried to follow your guides (Spru580g http://www.ti.com/lit/ug/spru580g/spru580g.pdf). 

Here are our #Defines

#define   SPCR (*((int *)0x028C0008))
#define RCR (*((int *)0x028C000C))
#define XCR (*((int *)0x028C0010))
#define SRGR (*((int *)0x028C0014))
#define PCR (*((int *)0x028C0024))
#define DXR (*((int *)0x028C0004))
#define DRR (*((int *)0x028C0000))


Our code:

void main()
{

/* Initialize the board support library, must be called first */
DSK6455_init();

/* Initialize LEDs and DIP switches */
DSK6455_LED_init();
DSK6455_DIP_init();
McBSP();

/* Clear buffers */
memset((void*)gBufferXmtPing,0,sizeof(gBufferXmtPing));
memset((void*)gBufferXmtPong,0,sizeof(gBufferXmtPong));
memset((void*)gBufferRcvPing,0,sizeof(gBufferRcvPing));
memset((void*)gBufferRcvPong,0,sizeof(gBufferRcvPong));



}

void McBSP()
{
int i;

SPCR = 0x00000000; //mcbsp resettii


//SPI-SLAVE conffit
RCR = 0x00000000; //kaikki nollina, koska DSP toimii slavena, ja 8 bittia siirretaan kerrallaan, jos olisi A0 lopussa, se tarkottaisi 32 bittia kerrallaan

XCR = 0x00000000;

SRGR = 0x2000007F; //THIS WAS THE FAULT SPOT, SRGR REGISTER SHOULD BE 0x20000001

PCR = 0x00000000;

SPCR = 0x00001800;




edmaInit();

SPCR |= 0x00010001;

for(i=0;i<1000;i++); {
}


}

 This code is based on your examples. Do you see any fundamental errors? We do not receive any data in the input register (data receive register).

Do you have example codes that we could study? 

Thanks for your time!

Edit: Problem solved, data moves just like it should be...

  • Could you share your code?

  • #include "dsk6455.h"

    #include <std.h>
    #include <log.h>
    #include <stdio.h> //C kirjasto
    #include <csl.h> //Chip support library
    #include <hwi.h> //Hardware interrupt
    #include <csl_mcbsp.h> //McBSP


    #include <c64.h>
    void McBSP(); 

    //McBSP defines
    #define SPCR (*((int *)0x028C0008)) //Serial Port Control Register
    #define RCR (*((int *)0x028C000C)) //Receive Control Register
    #define XCR (*((int *)0x028C0010)) //Transmit Control Register
    #define SRGR (*((int *)0x028C0014)) //Sample Rate Generator Register
    #define PCR (*((int *)0x028C0024)) //Pin Control Register
    #define DXR (*((int *)0x028C0004)) //Data Trasmit Register
    #define DRR (*((int *)0x028C0000)) //Data Receive Register

    void McBSP_init() //main program
    {

    McBSP(); //call for mcbsp subprogram

    }


    void McBSP() 
    {
    int j;
    SPCR = 0x00000000; //mcbsp to restet

    //SPI-SLAVE conf
    RCR = 0x00000000; //RCR bits to 0 because SPI SLAVE

    XCR = 0x00000000; //XCR bits to 0 because SPI SLAVE

    SRGR = 0x20000001; //Enable internal sample rate generator, and set CLKGDV ONE BIT to 1, for all spi speeds

    SPCR = 0x00001800; //CLKSTP confs

    SPCR |= 0x00400000; 

    for(j=0;j<1;j++);{ 
    }

    SPCR |= 0x00010001; 

    for(j=0;j<1;j++); {
    }

    }

    This is how it works for me. 

  • Thanks a lot, it is really useful for me!