Other Parts Discussed in Thread: REF5020,
void TLV5618_DAConvert(TLV5618_StatusTypeDef *p)
{
TLV5618_CS = 0;
p->_counter = Counter;
p->_vref = REF5020;
uint16_t SPD, Temp;
if(p->_SPD == 1)
SPD = 0x4000;
else SPD = 0x0000;
switch(p->_channel)
{
case Channel_A:
Temp = (p->_dataA & 0x0FFF) | SPD | 0x8000;
p->_dataS[0] = Temp >> 8 & 0x00FF;
p->_dataS[1] = Temp & 0x00FF;
HAL_SPI_Transmit(&spi_da, p->_dataS, 2, 5);
p->_VA = p->_vref * p->_dataA / p->_counter + 0.001;
break;
case Channel_B:
Temp = (p->_dataB & 0x0FFF) | SPD | 0x0000;
p->_dataS[0] = Temp >> 8 & 0x00FF;
p->_dataS[1] = Temp & 0x00FF;
HAL_SPI_Transmit(&spi_da, p->_dataS, 2, 5);
p->_VB = p->_vref * p->_dataB / p->_counter + 0.001;
break;
case Channel_AB:
break;
}
TLV5618_CS = 1;
}
//EOF
#include ...
extern TLV5618_StatusTypeDef TLV5618_Status = {0};
int main(void)
{
//STM32F103 初始化
STM32_Init();
//結構體賦值
TLV5618_Status._channel = Channel_A;
TLV5618_Status._dataA = 200;
TLV5618_Status._dataB = 0;
TLV5618_Status._SPD = 1;
//DA轉換
TLV5618_DAConvert(&tLV5618_Status);
while(1)
{};
}
主函数里面写A 通道值,B通道也有微量电压输出是什么原因?
————————————————
版权声明:本文为CSDN博主「浮生一城」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:blog.csdn.net/.../77206176