VREFBUF Enable Problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-07 06:46 AM
Hi,
I am working on STM32G474CET mcu. I am trying to use VREFBUFF voltage for ADC channel referance voltage. My configuration looks like the following.
When i run the code, it stuck in the HAL_SYSCFG_EnableVREFBUF function. Whenever i check the 'tickstart' variable it remains 0.
/**
* @brief Enable the Internal Voltage Reference buffer (VREFBUF).
* @retval HAL_OK/HAL_TIMEOUT
*/
HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void)
{
uint32_t tickstart;
SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
/* Get Start Tick*/
tickstart = HAL_GetTick();
/* Wait for VRR bit */
while (READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == 0x00U)
{
if ((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE)
{
return HAL_TIMEOUT;
}
}
return HAL_OK;
}
When i try the same configuration on empty project, it worked fine. So i can see its not about hardware. What am i missing?
- Labels:
-
ADC
-
STM32G4 Series
-
SysTick
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-07 07:21 AM
Hello @gunccc,
Have a look at this FAQ: How to configure VREFBUF on my STM32,
May be this post can help: 2 bugs with VREFBUF and STM32Cube on at least STM32G4
Otherwise, please share your ioc file to check the case, and precise which CubeMx et firmware package versions are you using?
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-08 05:45 AM
Hi @Imen.D .
Thank you for your answer. Like you said 2 bugs with VREFBUF and STM32Cube on at least STM32G491 post really helped me. Like bobert said, i enabled the low impedance before Vrefbuf. And like that my code worked. But I had to interfere the STM's code. In order to use the user code section, I also had to include the enabling of the clocks in the user code. Now my MspInit code looks like that.
void HAL_MspInit(void)
{
/* USER CODE BEGIN MspInit 0 */
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_RCC_PWR_CLK_ENABLE();
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
/* USER CODE END MspInit 0 */
__HAL_RCC_SYSCFG_CLK_ENABLE();
__HAL_RCC_PWR_CLK_ENABLE();
/* System interrupt init*/
/* PendSV_IRQn interrupt configuration */
HAL_NVIC_SetPriority(PendSV_IRQn, 15, 0);
/** Configure the internal voltage reference buffer voltage scale
*/
HAL_SYSCFG_VREFBUF_VoltageScalingConfig(SYSCFG_VREFBUF_VOLTAGE_SCALE0);
/** Enable the Internal Voltage Reference buffer
*/
HAL_SYSCFG_EnableVREFBUF();
/** Configure the internal voltage reference buffer high impedance mode
*/
HAL_SYSCFG_VREFBUF_HighImpedanceConfig(SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE);
/* USER CODE BEGIN MspInit 1 */
/* USER CODE END MspInit 1 */
}
Is it okay to use it like that or is there a better way to do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-08 05:57 AM
Also in using internal Vrefbuf : HAL Code generation issue post, people have used the same method as me and suggested this as a bug in HAL.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-08-17 07:39 AM
Hello,
I escalated this issue internally and internal ticket (ID 159452) is submitted to be reviewed and treated.
(PS: ID 159452 is an internal tracking number and is not accessible or usable by customers).
Imen
Thanks
Imen