AnsweredAssumed Answered

adsp-bf592 acting as spi slave

Question asked by Edd on Jun 26, 2014
Latest reply on Jul 1, 2014 by Edd

Hi

 

I am trying to use the blackfin as a SPI slave with an external CS:

 

Blackfin SPI1 (PG8, PG9, PG10, PG13) connected to a master SPI (SCK, MOSI, MISO, /SS)

 

By using the following code, I am unable to get an interrupt only when the PG13 chip select is down(active). I get an interrupt on every SPI transfer. I have read the documentation and I have no idea what I am doing wrong.

Is this possible with this blackfin?

 

<------------------------------------------------------------------>

#include <stddef.h>

#include <sys/platform.h>

#include <interrupt.h>

#include <builtins.h>

#include <bfrom.h>

 

EX_INTERRUPT_HANDLER(spiSlave_irq)

{

    uint16_t d;

 

    if((*pSPI1_STAT & RXS) != RXS) {

        d = *pSPI1_RDBR;

        return;

    }

 

    d = *pSPI1_RDBR;

    *pSPI1_TDBR = d;

}

 

int main(void)

{

    uint8_t dummy = 0;

 

    // use Blackfin ROM SysControl() to change the PLL

    ADI_SYSCTRL_VALUES sysctrl = {0x0000,

            0x4000,

            0x0004,

            0x0000,

            0x0000};

    bfrom_SysControl( SYSCTRL_WRITE | SYSCTRL_PLLCTL | SYSCTRL_PLLDIV, &sysctrl, NULL);

 

    *pPORTG_FER     |= (PG8 | PG9 | PG10);

    ssync();

 

//    *pSPI1_CTL = PSSE | EMISO | SIZE | SZ | CPHA | RDBR_CORE;

    *pSPI1_CTL = PSSE | EMISO | SIZE | SZ | RDBR_CORE;

    ssync();

 

    register_handler_ex(ik_ivg8,  spiSlave_irq, EX_INT_ENABLE);

    *pSIC_IAR1 &= ~(0x0F << 0x18);

    *pSIC_IAR1 |= P14_IVG(8);

    *pSIC_IMASK |= IRQ_DMA6;

    ssync();

    *pSPI1_CTL |= SPE;

    ssync();

    dummy = *pSPI1_RDBR;

 

    while(1) {

        dummy++;

    }

 

    return 0;

}

Outcomes