主题中讨论的其他器件: DAC8562
尊敬的团队:
我在项目中使用 DAC8563、我想为初始输出2.5V、输出2.5V 至5V 供电。 我在网上找到了一段 C 代码。
void DAC8562_WriteCmd (uint32_t _cmd)
{
uint8_t i;
SYNC_0();
对于(I = 0;I < 24;I++)
{
IF (_cmd & 0x800000)
{
DIN_1 ();
}
其他
{
DIN_0();
}
SCLK_1 ();
_cmd <<= 1;
SCLK_0();
}
SYNC_1 ();
}
void bsp_InitDAC8562 (void)
{
GPIO_InitTypeDef GPIO_InitStructure;
#ifdef SOFT_SPI
SYNC_1 ();/* SYNC = 1 */
RCC_AHB1 PeriphClockCmd (RCC_SCLK | RCC_DIN | RCC_SYNC、ENABLE);
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Pud = GPIO_PUT_NOPULL;
GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Pin = PIN_SCLK;
GPIO_Init (PORT_SCLK、&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_DIN;
GPIO_Init (PORT_DIN、&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = PIN_SYNC;
GPIO_Init (PORT_SYNC、&GPIO_InitStructure);
#endif
/*为 DAC-A 和 DAC-B 加电*/
DAC8562_WriteCmd ((4 << 19)|(0 << 16)|(3 << 0));
对于 DAC-B 和 DAC-B,/* LDAC 引脚处于非活动状态,在不使用 LDAC 引脚的情况下更新数据*/
DAC8562_WriteCmd ((6 << 19)|(0 << 16)|(3 << 0));
/*将2个 DAC 重置为中间值、输出2.5V */
DAC8562_setData (0、32767);
DAC8562_setData (1、32767);
/*选择内部基准并复位2个 DAC 的增益= 2 (复位时内部基准被禁用)*/
DAC8562_WriteCmd ((7 << 19)|(0 << 16)|(1 << 0));
}
我 不理解这些代码。 这些是技术手册上的相应寄存器设置。
/*为 DAC-A 和 DAC-B 加电*/ DAC8562_WriteCmd ((4 << 19)|(0 << 16)|(3 << 0));
对于 DAC-B 和 DAC-B,/* LDAC 引脚不活动,在不使用 LDAC 引脚的情况下更新数据*/ DAC8562_WriteCmd ((6 << 19)|(0 << 16)|(3 << 0));
/*选择内部基准并复位2个 DAC 的增益= 2 (复位时禁用内部基准)*/ DAC8562_WriteCmd ((7 << 19)|(0 << 16)|(1 << 0));
谢谢你。