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.

how to use dm365 SPI as slave?

hi all:

 as the title says, i use spi2@CS0 as slave, and I config the SPI2 register as below:

clkmod=master=0;

somifun=simofun=sclkfun=1,scs1fun=0,scsfun=1;

cshold=1,dfsel=0,csnr=2;

scs1def=scs0def=1;

shiftdir=0,polarity=0,phase=0,charlen=0;

finally set SPIEN=1,

So I write data to SPIDAT1 to send out the data.

However, when the clock and cs coming, it just shift two bytes. and never shift any more.

when the second clock and cs come , it also shift two bytes.

Question1: In kernel driver code , I saw a register named SPIDAT0, can we use it? because I cannot see

any explanation about it.

Question2: what is the trigger condition starting shifting the data? is when the CS becomes active? or when the clock become active?

Any tips will be appreciated !

  • hello?

    I use following code :

    count = 0;

    data1_reg_val = pdata->cs_hold << SPIDAT1_CSHOLD_SHIFT;

    data1_reg_val |= (2<<SPIDAT1_CSNR_SHIFT);

    while (count<GLOBAL_BUFFER_SIZE)

    {

        data1_reg_val &=~0xFFFF;

        buf_reg_val = __raw_readl(davinci_spi->base + SPIBUF);

        //look if we can write

        if((buf_reg_val & SPIBUF_TXFULL_MASK) ==0)

        __raw_writel(data1_reg_val|(count&0xffff),davinci_spi->base + SPIDAT1);

        //wait for rx,but ignor

        while (__raw_readl(davinci_spi->base + SPIBUF) & SPIBUF_RXEMPTY_MASK)

        cpu_relax();

        count++;

        DBG("%d\n",count);

    }

    DBG("get out\n");

    return 1; 

    DM365 is operated as SPI slave,BUT, no matter what length I read, it can just only output two bytes. that's to say:

    when I read 8 byte , it output 2 byte, when I read 4 byte , it also output 2 byte, 

    From the datasheet , it seems only can output the data in shift register and txbuf register. until another CS0 pin level change!

    Any tips?

    TI employee?