📄 f411_vr_dpcm.c
字号:
{
dpcm_code = 57;
}
// fifth tier
else
{
dpcm_code = 56;
}
}
}
}
// second tier
else
{
// third tier
if (sample_diff_us >= quant20)
{
// fourth tier
if (sample_diff_us >= quant22)
{
// fifth tier
if (sample_diff_us >= quant23)
{
dpcm_code = 55;
}
// fifth tier
else
{
dpcm_code = 54;
}
}
// fourth tier
else
{
// fifth tier
if (sample_diff_us >= quant21)
{
dpcm_code = 53;
}
// fifth tier
else
{
dpcm_code = 52;
}
}
}
// third tier
else
{
// fourth tier
if (sample_diff_us >= quant18)
{
// fifth tier
if (sample_diff_us >= quant19)
{
dpcm_code = 51;
}
// fifth tier
else
{
dpcm_code = 50;
}
}
// fourth tier
else
{
// fifth tier
if (sample_diff_us >= quant17)
{
dpcm_code = 49;
}
// fifth tier
else
{
dpcm_code = 48;
}
}
}
}
}
// first tier
else
{
// second tier
if (sample_diff_us >= quant8)
{
// third tier
if (sample_diff_us >= quant12)
{
// fourth tier
if (sample_diff_us >= quant14)
{
// fifth tier
if (sample_diff_us >= quant15)
{
dpcm_code = 47;
}
// fifth tier
else
{
dpcm_code = 46;
}
}
// fourth tier
else
{
// fifth tier
if (sample_diff_us >= quant13)
{
dpcm_code = 45;
}
// fifth tier
else
{
dpcm_code = 44;
}
}
}
// third tier
else
{
// fourth tier
if (sample_diff_us >= quant10)
{
// fifth tier
if (sample_diff_us >= quant11)
{
dpcm_code = 43;
}
// fifth tier
else
{
dpcm_code = 42;
}
}
// fourth tier
else
{
// fifth tier
if (sample_diff_us >= quant9)
{
dpcm_code = 41;
}
// fifth tier
else
{
dpcm_code = 40;
}
}
}
}
// second tier
else
{
// third tier
if (sample_diff_us >= quant4)
{
// fourth tier
if (sample_diff_us >= quant6)
{
// fifth tier
if (sample_diff_us >= quant7)
{
dpcm_code = 39;
}
// fifth tier
else
{
dpcm_code = 38;
}
}
// fourth tier
else
{
// fifth tier
if (sample_diff_us >= quant5)
{
dpcm_code = 37;
}
// fifth tier
else
{
dpcm_code = 36;
}
}
}
// third tier
else
{
// fourth tier
if (sample_diff_us >= quant2)
{
// fifth tier
if (sample_diff_us >= quant3)
{
dpcm_code = 35;
}
// fifth tier
else
{
dpcm_code = 34;
}
}
// fourth tier
else
{
// fifth tier
if (sample_diff_us >= quant1)
{
dpcm_code = 33;
}
// fifth tier
else
{
dpcm_code = 32;
}
}
}
}
}
// convert the DPCM code to its 2's compliment if the original sample
// difference was negative
// For example, 41 (101001), which represents a difference of 60, 2's
// complimented becomes 23 (010111), which represents a difference of -60
if (sample_diff < 0)
{
dpcm_code = ~dpcm_code + 1; // use the 2's compliment of the dpcm
// code
dpcm_code &= 0x3F; // use only the 6 LSBs for the dpcm code
}
return dpcm_code;
}
//-----------------------------------------------------------------------------
// DPCM_Decode
//-----------------------------------------------------------------------------
//
// Return Value :
// 1) short predicted_value - the signed and quantized difference between
// the predicted_value and the ADC sample, which is used
// create the predicted_value for the next DPCM cycle
// range is: -4096 to 4095 (difference of 12-bit values)
// Parameters :
// 1) char dpcm_code - the 6-bit code indicating the quantized difference
// between the old_prediction and the current sample value
// range is positive range of 6-bit value: 0 to 63
//
// Decode the DPCM code to a signed difference between the current predicted
// value and the next.
//
// NOTE: the calling function must have the same register context, so it must
// either have the keyword "using 2" or all "using 2" keywords need to be
// removed
short DPCM_Decode (unsigned char dpcm_code) using 2
{
return Q_VALUES[dpcm_code];
}
//-----------------------------------------------------------------------------
// End Of File
//-----------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -