Stan woldes
Stan woldes

Reputation: 35

STM32 SPI Interrupt & DMA not working, polling is

I'm using STM32H7A3 nucleo, manage to get SPI polling working, enclose code below, when I try in implement Interrupt and DMA , the code compile successfully with no error, but SPI outputs no signal. SPI slave device is a TI ADC. I have set SPI global interrupt and DMA circular.

HAL_StatusTypeDef spi_write(reg, *pData)
{
  HAL_StatusTypeDef ret;
  uint8_t sendData[2] = {reg, *pData};
 
  HAL_GPIO_WritePin(...);  // CS pull low
  ret = HAL_SPI_Transmit_IT(&hspi1, sendData, 2, 20);
// ret = HAL_SPI_Transmit_DMA(&hspi1, sendData, 2, 20);
  if  (ret != HAL_OK)
  {
              HAL_GPIO_WritePin(..);  // CS high
  }

The code is working for polling. TI ADC is able to read and sent data, but not interrupt and DMA mode.

Hello, anyone can kindly advise...thx

Upvotes: 2

Views: 415

Answers (1)

gulpr
gulpr

Reputation: 4598

Both functions are not blocking, only set up the transition and return immediately.

It means that they do not wait until the transition is completed.

Then you pull the CS up before the transition ends. You need to do it in the interrupt callbacks/

Upvotes: 0

Related Questions