Receiving SPDIF data with STM32F446RET/CubeMX does not work
I'm trying to receive SPDIF data using an STM32F446RET using PB7 as SPDIFRX. The signal itself is perfect, a clear and sharp waveform can be seen directly at the input pin. The whole stuff is configured in CubeMX which also generated the code for interrupt data reception. From what I can see in the CubeMX-generated code, there is no obvious mistake. The major configuration looks like this:
hspdif.Instance = SPDIFRX;
hspdif.Init.InputSelection = SPDIFRX_INPUT_IN0;
hspdif.Init.Retries = SPDIFRX_MAXRETRIES_63;
hspdif.Init.WaitForActivity = SPDIFRX_WAITFORACTIVITY_ON;
hspdif.Init.ChannelSelection = SPDIFRX_CHANNEL_A;
hspdif.Init.DataFormat = SPDIFRX_DATAFORMAT_LSB;
hspdif.Init.StereoMode = SPDIFRX_STEREOMODE_ENABLE;
hspdif.Init.PreambleTypeMask = SPDIFRX_PREAMBLETYPEMASK_ON;
hspdif.Init.ChannelStatusMask = SPDIFRX_CHANNELSTATUS_ON;
hspdif.Init.ValidityBitMask = SPDIFRX_VALIDITYMASK_ON;
hspdif.Init.ParityErrorMask = SPDIFRX_PARITYERRORMASK_ON;
if (HAL_SPDIFRX_Init(&hspdif) != HAL_OK)
{
Error_Handler();
}
...
GPIO_InitStruct.Pin = GPIO_PIN_7;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF8_SPDIFRX;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* SPDIFRX interrupt Init */
HAL_NVIC_SetPriority(SPDIF_RX_IRQn, 0, 5);
HAL_NVIC_EnableIRQ(SPDIF_RX_IRQn);Interrupts (both, global and the SPDIF-one) are enabled and data reception is initiated via a call to:
if (HAL_SPDIFRX_ReceiveDataFlow_IT(&hspdif,recvBuffer,8)==HAL_OK)
{
spdifRecvComplete=0;
}The interrupt routine to announce the completion of data reception looks like this:
void HAL_SPDIFRX_RxCpltCallback(SPDIFRX_HandleTypeDef *hspdif)
{
spdifRecvComplete=1;
}So the whole code is more or less some straight-forward stuff which makes use if the HAL-interface's interrupt data transfer functionality.
My problem: this routine is never called. More than this, the low-level interrupt service function SPDIF_RX_IRQHandler() is also never called. One strange thing: I see the function SPDIF_RX_IRQHandler(), its definition but I can not see where it is defined as interrupt handler/where a pointer to this function is handed over to some IRQ hardware register.
As said, the SPDIF input signal is perfect, the only special thing here: it comes with 100 kHz clock, not 96 kHz or 192 kHz or something common like that.
So what could be the reason for my problems? Why are no SPDIF data received?
