简体   繁体   English

STM32L0上的VREF输出

[英]VREF Output on STM32L0

I have an STM32L051 and want to drive an external DAC (SPI). 我有一个STM32L051,想驱动一个外部DAC(SPI)。

For that I would like to use the feature, mentioned in the manual , to output the internal reference voltage to the PB1 pin of the STM32. 为此,我想使用手册中提到的功能将内部参考电压输出到STM32的PB1引脚。

I use the STM32Cube HAL as a basis. 我使用STM32Cube HAL作为基础。 However the examples of using the VREF are limited to internal use for ADCs and comparators. 但是,使用VREF的示例仅限于ADC和比较器内部使用。

If I understand correctly, I can use the CFGR3 register to both enable the VREF as well as connect it to the PB1. 如果我理解正确,我可以使用CFGR3寄存器来使能VREF并将其连接到PB1。 Using the Cube drivers, I can use the HAL_SYSCFG_VREFINT_OutputSelect(SYSCFG_VREFINT_OUT_PB1) function, but to enable it, I should use either HAL_ADCEx_EnableVREFINT() or HAL_COMPEx_EnableVREFINT() . 使用多维数据集驱动程序,我可以使用HAL_SYSCFG_VREFINT_OutputSelect(SYSCFG_VREFINT_OUT_PB1)函数,但是要启用它,我应该使用HAL_ADCEx_EnableVREFINT()HAL_COMPEx_EnableVREFINT() The manual information on SEL_VREF_OUT indicates that ENBUF_VREFINT_ADC must be set. SEL_VREF_OUT上的手册信息指示必须设置ENBUF_VREFINT_ADC

Furthermore no mention is made about the configuration of the pin itself. 此外,未提及销本身的构造。 Should I simply declare it as a DAC Pin? 我应该简单地将其声明为DAC引脚吗? An ADC Pin? ADC引脚?

Answer 回答

It is as simple as 就这么简单

if ( HALD_ADCEx_EnableVREFINT() != HAL_OK )
{
  Error_Handling();
}
HAL_SYSCFG_VREFINT_OutputSelect(SYSCFG_VREFINT_OUT_PB1);

And I can see the 1.22 V on the PB1 output. 我可以在PB1输出上看到1.22V。

It does not require further pin (GPIO) configuration. 它不需要进一步的引脚(GPIO)配置。


Complications and justification for the question (can be skipped) 问题的复杂性和理由(可以跳过)

I had some issues with the board from out electronic dept. 我在电子部门的董事会中遇到了一些问题。 and thus switched to the STM32L053-Discovery board. 从而切换到STM32L053-发现板。 The above solution did not work, and I kept seeing 0V on PB1 (or PB0). 上面的解决方案不起作用,我一直在PB1(或PB0)上看到0V。

I assumed that was due to some configuration missing. 我认为那是由于缺少一些配置。 However, after some further tests, I actually found that on that Discovery board, both PB1 and PB0 are reserved for a sensor. 但是,经过一些进一步的测试,我实际上发现在该发现板上,PB1和PB0都保留用于传感器。 By closing the SB23 bridge, I could use PB1 back to the GPIO, and thus see the reference voltage on the pin. 通过关闭SB23桥接器,我可以将PB1使用回GPIO,从而查看引脚上的参考电压。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM