2022-12-11 08:37 AM
Dear Sir.
Attached a code of SystemClock_Config();
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Configure the main internal regulator output voltage
*/
if (HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1) != HAL_OK)
{
Error_Handler();
}
/** Configure LSE Drive Capability
*/
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_HIGH);
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|
RCC_OSCILLATORTYPE_LSE|
RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = RCC_MSICALIBRATION_DEFAULT;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_0;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2
|RCC_CLOCKTYPE_PCLK3;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB3CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
{
Error_Handler();
}
/** LSCO configuration , 32.768 khz to LPTIM2. */
HAL_RCCEx_EnableLSCO(RCC_MCO1SOURCE_LSE);
/** MCO configuration , 32.768 khz to MAX3000X. */
HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCO1SOURCE_LSE, RCC_MCODIV_1);
#endif
when line 24 is enabled RCC_OscInitStruct.LSEState = RCC_LSE_ON;
I get 32.khz on pin PA2 , even if PA2 is configures as analog input.
When line 24 is commented , no 32khz on PA2.
How to resolve this issue . I must use PA2 as analog. The PCB is already designed.
Please Advise.
Solved! Go to Solution.
2022-12-13 06:34 AM
OK, so "getting close" means that there is some output of the ADC, which is not correct?
If you can swap the inputs on the PCB, do it. Otherwise you will need to compute the correct value in software.
BR,
Jaroslav
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-12 06:08 AM
Hi @Community member,
in your code (line 56), you have switched on the LSCO (low-speed clock output), which is on STM32U5xx only on pin PA2:
/** LSCO configuration , 32.768 khz to LPTIM2. */
HAL_RCCEx_EnableLSCO(RCC_MCO1SOURCE_LSE);
If you do not need the low-speed clock external output, you can delete this line. After that, you won't see those 32 kHz on PA2.
BR,
Jaroslav
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-12 07:37 AM
Hi.
To be more spsecific I need the following
I deleted the line HAL_RCCEx_EnableLSCO(RCC_MCO1SOURCE_LSE);
32khz still appears on PA2 ,
Only if I add the line HAL_RCCEx_DisableLSCO(); I don't get 32kz on PA2 ,
but PA2 is not working well as analog diffferenatil
Thans
2022-12-13 12:13 AM
Hi,
regarding your questions:
BR,
Jaroslav
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-13 12:52 AM
Hi.
I can send you github link . How can I do it privately ?
2022-12-13 01:01 AM
You can send me a private message here, or contact me via e-mail jaroslav.janos@st.com
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-13 03:20 AM
2022-12-13 03:27 AM
Instead of posting code/link to code, read out and check/post content of ADC and relevant GPIO registers; and describe what's your related hardware, how do you observe the "is not working well" state and how does it differ from your expectations.
Also note, that in STM32, ADC in differential mode has a very restricted common-mode voltage.range.
JW
2022-12-13 06:34 AM
OK, so "getting close" means that there is some output of the ADC, which is not correct?
If you can swap the inputs on the PCB, do it. Otherwise you will need to compute the correct value in software.
BR,
Jaroslav
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2022-12-13 11:56 PM
Hi.
It works fine , Many Thanks