AnsweredAssumed Answered

SPI & DMA - DMA irq not called out 2

Question asked by snafu.sn on Jun 1, 2011
Latest reply on Jun 27, 2011 by snafu.sn
Hello,

I encountered problems when trying to send SPI data by means of DMA. It seems that DMA transfer never starts. The sequence of configurations commands is as follow:

1) Enable SPI and DMA clocks
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA, ENABLE);
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
2) Init of DMA
    DMA_DeInit(cfg->txDMAChannel);
    tmpreg |= DMA_PeripheralDataSize_Byte | DMA_MemoryDataSize_Byte | DMA_Mode_Normal | DMA_Priority_VeryHigh | DMA_MemoryInc_Disable | DMA_M2M_Disable
| DMA_DIR_PeripheralDST;
    cfg->txDMAChannel->CCR = tmpreg;
3) SPI initialization
   SPI_DeInit(cfg->SPIx);
   cfg->SPIx->CR1 = 0x002F; //BR == 5; MSTR, CPOL, CPHA == 1
   cfg->SPIx->CR2 = 0x03;    //SPI_CR2_TXDMAEN;
4) Enable SPI
   cfg->SPIx->CR1 |= 0x40;

6) Enable DMA irq in NVIC

7) Transaction (transmission) is started as follows
    DMA_Cmd( cfg->txDMAChannel, DISABLE);
   
cfg->txDMAChannel->CMAR = (u32)tr->txBuf; //tx buffer ptr
   
cfg->txDMAChannel->CPAR = (u32)&cfg->SPIx->DR; //SPI DR reg addr
   
cfg->txDMAChannel->CNDTR = (u32)tr->len; //4
    tmp = txDMA->CCR & 0xFF70; /* Clear flags: MINC, TEIE, HTEIE, TCIE, EN */
    tmp |= DMA_MemoryInc_Enable | DMA_IT_TE | DMA_IT_TC;
   
cfg->txDMAChannel->CCR = tmp;
   DMA_Cmd(txDMA, ENABLE);
Now I suppose the transaction should get started and after the last send byte, DMA irq should be called out. But nothing like this happens.


When I try to send data without DMA, SPI irq is always called out when TxE is set.


The contents of the relevant registers right after the transaction starts is as follows
DMA_CCR6 == 0x0000309B
DMA_CNDTR == 4
DMA_CPAR ==0x4001300C
DMA_CMAR ==0x200000D4

SPI1_CR1 == 0x6F //BR=5;MSTR, CPOL, CPHA ==1
SPI1_CR2 == 2 // TXDMAEN
SPI1_SR == 2 //TxE

I'll be grateful for any advice or hint.

Thank you

Outcomes