cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H7 SAI can't use fifo request interrupt

SeyyedMohammad
Senior III

The code is:

 hsai_BlockB2.InterruptServiceRoutine = fifoReqCallback;

void fifoReqCallback(SAI_HandleTypeDef *hsai)

{

if(hsai->Instance = SAI2_Block_B)

{

HAL_GPIO_TogglePin(test_GPIO_Port, test_Pin);

}

HAL_SAI_Receive_DMA(&hsai_BlockB2, (uint8_t*)&noisebuf[0], BLOCK_SIZE*3);

__HAL_SAI_ENABLE_IT(&hsai_BlockB2,SAI_IT_FREQ);

HAL_Delay(5);

The resualt is: lots of fifo request interrupt, prevent loop to execute.

Also I know datasheet warning: "When this bit is set, an interrupt is generated if the FREQ bit in the SAI_xSR register is set. Since the audio block defaults to operate as a transmitter after reset, the MODE bit must be configured before setting FREQIE to avoid a parasitic interrupt in receiver mode". I think it sadly means in acrual you can not benefit from fifo request interrupt in Tx mode.

1 ACCEPTED SOLUTION

Accepted Solutions
SeyyedMohammad
Senior III

Because to remove interupt source we need to surve it by reading or writing to/from DR of SAI.

The working code:

 hsai_BlockB2.InterruptServiceRoutine = fifoReqCallback;

 __HAL_SAI_ENABLE_IT(&hsai_BlockB2,SAI_IT_FREQ);

 __HAL_SAI_ENABLE(&hsai_BlockB2);

 while (1)

 {

//  while(hsai_BlockB2.State != HAL_SAI_STATE_READY);

//  HAL_SAI_Receive(&hsai_BlockB2, (uint8_t*)&noisebuf[0], BLOCK_SIZE*3,10);

if(saicount==10)

{

__HAL_SAI_DISABLE(&hsai_BlockB2);

HAL_Delay(1);

__HAL_SAI_ENABLE(&hsai_BlockB2);

saicount=0;

}

 }

}

void fifoReqCallback(SAI_HandleTypeDef *hsai)

{

if(hsai->Instance = SAI2_Block_B)

{

HAL_SAI_Receive(&hsai_BlockB2, (uint8_t*)&adcbuf[0], 1,10);

saicount++;

HAL_GPIO_TogglePin(test_GPIO_Port, test_Pin);

}

}

View solution in original post

1 REPLY 1
SeyyedMohammad
Senior III

Because to remove interupt source we need to surve it by reading or writing to/from DR of SAI.

The working code:

 hsai_BlockB2.InterruptServiceRoutine = fifoReqCallback;

 __HAL_SAI_ENABLE_IT(&hsai_BlockB2,SAI_IT_FREQ);

 __HAL_SAI_ENABLE(&hsai_BlockB2);

 while (1)

 {

//  while(hsai_BlockB2.State != HAL_SAI_STATE_READY);

//  HAL_SAI_Receive(&hsai_BlockB2, (uint8_t*)&noisebuf[0], BLOCK_SIZE*3,10);

if(saicount==10)

{

__HAL_SAI_DISABLE(&hsai_BlockB2);

HAL_Delay(1);

__HAL_SAI_ENABLE(&hsai_BlockB2);

saicount=0;

}

 }

}

void fifoReqCallback(SAI_HandleTypeDef *hsai)

{

if(hsai->Instance = SAI2_Block_B)

{

HAL_SAI_Receive(&hsai_BlockB2, (uint8_t*)&adcbuf[0], 1,10);

saicount++;

HAL_GPIO_TogglePin(test_GPIO_Port, test_Pin);

}

}