This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

UCD3138 读取输入电压

Other Parts Discussed in Thread: UCD3138

UCD3138 EVM的源代码如下,计算pmbus回读的地址,当filtered_vin=1F0时,为什么value=E340呢?是怎样计算的?

inline Uint8 pmbus_read_vin(void)
{
Uint16 value;
//This struct represents the floating point number: 0.1055
struct qnote constant_0_1035 = {27126 , -18};
value = qnote_to_linear11(qnote_scale(constant_0_1035, filtered_vin));
pmbus_read_two_byte_handler(value);

return 0;
}

struct qnote qnote_scale (struct qnote x, int16 y)
{
struct qnote final;
int32 mantissa;
final.exponent = x.exponent;

mantissa = (int32)x.mantissa * (int32)y;
while(abs(mantissa) > 0x00007FFF)
{
mantissa = mantissa >> 1;
final.exponent = final.exponent + 1;
}
final.mantissa = mantissa;

return final;
}

int16 qnote_to_linear11 (struct qnote x)
{
int16 linear11;

while(abs(x.mantissa) > 0x3FF)
{
x.mantissa = x.mantissa >> 1;
x.exponent = x.exponent + 1;
}
linear11 = (x.exponent << 11) + (x.mantissa & 0x07FF);

return linear11;
}