Solved
STM32L476JG DMA MEMORY ---> SAI2-A
Have a file and I am trying to transfer it to SAI2. For some reason ???? I am not getting into the DMA Callback. DMA is in normal mode. Can anyone shed any light on this?
/* USER CODE BEGIN 2 */
HAL_DMA_RegisterCallback(&hdma_sai2_a, HAL_DMA_XFER_CPLT_CB_ID, &DMA_XferCmplt_Callback);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
if (ISR.DMA_TxCmplt)
{
ISR.DMA_TxCmplt = F;
/*
* after each DMA check if high current
* if NOT then disable SAI dma
*/
if (adcValue[1] < (HIGH_CURRENT))
hsai_BlockA2.Instance->CR1 &= ~SAI_xCR1_DMAEN;
}
if (ISR.A_ConversionComplete)
{
ISR.A_ConversionComplete = F;
/*
* checks to see if actuator has
* bottomed out due to high current
*/
if (adcValue[1] > (HIGH_CURRENT))
{
hsai_BlockA2.Instance->CR1 |= SAI_xCR1_DMAEN;
/*
* if we are engaging and high current
* shut off motor drive and alarm
*/
if (ISR.Sw_EngageFlag)
{
HAL_GPIO_WritePin(MotorCntrlA_GPIO_Port, MotorCntrlA_Pin, GPIO_PIN_RESET);
PlayAudio(a4_tone, a4_tone_length);
ISR.Sw_EngageFlag = F;
}
/*
* if we are dis-engaging and high current
* shut off motor drive and alarm
*/
if (ISR.Sw_DisengageFlag)
{
HAL_GPIO_WritePin(MotorCntrlB_GPIO_Port, MotorCntrlB_Pin, GPIO_PIN_RESET);
PlayAudio(a4_tone, a4_tone_length);
ISR.Sw_DisengageFlag = F;
}
//dma buffer created by PlayAudio to audio chip
HAL_DMA_Start_IT(&hdma_sai2_a, (uint32_t)playout_buffer, (uint32_t)&hsai_BlockA2.Instance->DR, a4_tone_length);
}
}
void PlayAudio(const int16_t *buffer, int32_t n_samples)
{
for (int i=0; i < n_samples; i++) { // Duplicate each sample. The SAI insists on 2 channels of mono
playout_buffer[i*2] = buffer[i] * LEVEL_REDUCTION;
playout_buffer[i*2+1] = buffer[i] * LEVEL_REDUCTION;
}
}
void DMA_XferCmplt_Callback(DMA_HandleTypeDef *hdma)
{
if (hdma == &hdma_sai2_a)
ISR.DMA_TxCmplt = T;
}