Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

SPI slave using EDMA3 (C6748 platform)

$
0
0

Hi, There is the source code in my project.

main function:

spi_setup(DEFAULT_SPI_BUS, DEFAULT_SPI_CS, DEFAULT_SPI_MODE, NULL);  //setup spi0 (slave mode) cs=2

IntRegister(C674X_MASK_INT4, spi_edma3_com_isr);
IntRegister(C674X_MASK_INT5, spi_edma3_err_isr);

IntEventMap(C674X_MASK_INT4, SYS_INT_EDMA3_0_CC0_INT1);
IntEventMap(C674X_MASK_INT5, SYS_INT_EDMA3_0_CC0_ERRINT);

IntEnable(C674X_MASK_INT4);
IntEnable(C674X_MASK_INT5);

/* Request DMA Channel and TCC for SPI Transmit*/
EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, \
EDMA3_CHA_SPI0_TX, EDMA3_CHA_SPI0_TX, 0);

/* Request DMA Channel and TCC for SPI Receive*/
EDMA3RequestChannel(SOC_EDMA30CC_0_REGS, EDMA3_CHANNEL_TYPE_DMA, \
EDMA3_CHA_SPI0_RX, EDMA3_CHA_SPI0_RX, 0);

/* Registering Callback Function for Transmission. */
cb_Fxn[EDMA3_CHA_SPI0_TX] = &spi_edma_callback;
/* Registering Callback Function for Reception. */
cb_Fxn[EDMA3_CHA_SPI0_RX] = &spi_edma_callback;

 //set the PaRAM entries of EDMA3 for the Receive Channel of SPI0.   disable tx

spi_edma_rx((unsigned char *)dma_rx, 8);

spi_int_enable(spi, SPI_DMA_REQUEST_ENA_INT);

*************************************************************************************************************

spi_edma3_com_isr:     //spi_edma_callback

static void spi_edma_callback(unsigned int tccnum, unsigned int status)
{

if(tccnum == EDMA3_CHA_SPI0_TX)
{
EDMA3DisableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI0_TX, EDMA3_TRIG_MODE_EVENT);

spi_edma_rx((unsigned char *)dma_rx, 8);

}

}
else if(tccnum == EDMA3_CHA_SPI0_RX)
{
EDMA3DisableTransfer(SOC_EDMA30CC_0_REGS, EDMA3_CHA_SPI0_RX, EDMA3_TRIG_MODE_EVENT);

spi_edma_tx(data, 8);

}
}

It works fine when I just used edma for receiveing. After I used "EDMA3DisableTransfer" to disable rx and used "EDMA3EnableTransfer" to enable tx, it works fine too. But the C6748 will receive 3 extra bytes after I used "EDMA3DisableTransfer" to disable tx dma and used "EDMA3EnableTransfer" to enable rx dma,.

For example:

Master send: 0xa8 0xb8 0x00 0x11 0x22 0x45 0x55 0x90

slave receive: 0xa8 0x00 0x00 0xa8 0xb8 0x00 0x11 0x22       0x45 0x55 0x90(this 3 bytes will be lost)

The "0xa8 0x00 0x00" were not transmited by the master. Is there any problem in my code? 


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>