AnsweredAssumed Answered

CubeMx dma spi:Getting spi overrun

Question asked by Kauppi.Teijo on Jan 24, 2017
Latest reply on Jan 24, 2017 by Kauppi.Teijo



I'm using latest version of Cube (download 20.01). I'm trying to read ADC-values from SPI with DMA. Read is activated on ADC-dataready.


#define ADC_BLOCK_SIZE 24

uint8_t tempBuf[ADC_BLOCK_SIZE ];

// This interrupt is called every 100 us.

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)


    status =  HAL_SPI_Receive_DMA(&hspi1, tempBuf, ADC_BLOCK_SIZE);


First read calls the DMA ready Callback correctly

HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi)


but further interrupts cause SPI overrun error and transfer stops. Any ideas what to do differently?

APB2 is at 42 MHz


I tested the same transfer with SPI polling method and it was working without errors.


/* SPI1 init function */
static void MX_SPI1_Init(void)


  hspi1.Instance = SPI1;
  hspi1.Init.Mode = SPI_MODE_MASTER;
  hspi1.Init.Direction = SPI_DIRECTION_2LINES_RXONLY;
  hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
  hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
  hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
  hspi1.Init.NSS = SPI_NSS_SOFT;
  hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_4;
  hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
  hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
  hspi1.Init.CRCPolynomial = 10;
  if (HAL_SPI_Init(&hspi1) != HAL_OK)