【发布时间】:2018-11-29 15:39:13
【问题描述】:
我使用 SAMD21 Xplained 板。我运行 Atmel Studio 提供的 DAC 示例:DAC_QUICKSTART1
在示例附带的头文件(dac_feature.h)中,我有以下枚举:
enum dac_reference {
/** 1V from the internal band-gap reference*/
DAC_REFERENCE_INT1V = DAC_CTRLB_REFSEL(0),
/** Analog V<SUB>CC</SUB> as reference */
DAC_REFERENCE_AVCC = DAC_CTRLB_REFSEL(1),
/** External reference on AREF */
DAC_REFERENCE_AREF = DAC_CTRLB_REFSEL(2),
};
原来,参考电压是内部1V电压。我想使用外部参考,这样 DAC 输出可以在 0V 到 5V 之间变化。
我的问题是:我该如何设置这些设置?
在同一个文件-dac_feature.h中,有如下结构:
struct dac_config {
/** Reference voltage */
enum dac_reference reference;
/** Select DAC output */
enum dac_output output;
/** Left adjusted data */
bool left_adjust;
/** GCLK generator used to clock the peripheral */
enum gclk_generator clock_source;
#ifdef FEATURE_DAC_DATABUF_WRITE_PROTECTION
/** Bypass DATABUF write protection */
bool databuf_protection_bypass;
#endif
/** Voltage pump disable */
bool voltage_pump_disable;
/**
* The DAC behaves as in normal mode when the chip enters STANDBY sleep
* mode
*/
bool run_in_standby;
#if (SAMC21)
/** Dither mode enable data */
bool dither_mode;
#endif
};
这里创建了dac_reference 的实例,称为引用。我认为这就是它完成的地方,但我仍然不确定如何。
任何帮助表示赞赏。
【问题讨论】:
标签: atmel atmelstudio asf samd21