About STM32L4 ADC and SD interface problem
I have nucleo-64 STM32L476 board. I have initialised ADC. I am able to read all the three channels ( that I configured in cube Mx) correctly using DMA.
Then I added SD interface. I was able to read and write in the SD Card as well. But as soon as I initialise SD card, my ADC readings gets distorted ( not correct).
SO I traced at which point of SD intialisation this happens and found that as soon as
/* Enable SDMMC Clock */ ( in file STM32L4xx_hal_sd.c and function HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd) )
__HAL_SD_ENABLE(hsd); is executed, the ADC reading gets distorted.
SO commented this line, for testing purpose and found that ADC reads correctly.
Now clock configuration is that ADC CLk is at 12 Mhz and SDMMC Clk = 48 Mhz
both derived from PLLSAI1
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC|RCC_PERIPHCLK_USART2
|RCC_PERIPHCLK_SDMMC1|RCC_PERIPHCLK_ADC;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI1;
PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE;
PeriphClkInit.Sdmmc1ClockSelection = RCC_SDMMC1CLKSOURCE_PLLSAI1;
PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE;
PeriphClkInit.PLLSAI1.PLLSAI1M = 1;
PeriphClkInit.PLLSAI1.PLLSAI1N = 12;
PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7;
PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;
PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV8;
PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK|RCC_PLLSAI1_ADC1CLK;
can any body help to sort this problem.
Thanks in advance.
Thanks
Hitesh