Hi all,
I want to convert a signed 16-bit to un-signed 12-bit format,
The real sinusoidal waveform varies between -200 and 200 [0,...,200,...,0,...,-200,...,0], this wave is stored in a signed 16-bit (int16)
I want to convert the 16 bits signed to 12bit un-signed format, the idea is to use the 12-bit DAC to output this waveform,
I found this code in the TI labs, this code does the same thing for a waveform varies between -90 and 90 [0,...,90,...,0,...,-90,...,0].,
dacOutput = dacOffset + ((QuadratureTable[resultsIndex % 0x20] ^ 0x8000) >> 5);
int QuadratureTable[40] = {
0x0000, // [0] 0
0x18F8, // [1] 11.25
0x30FB, // [2] 22.50
0x471C, // [3] 33.75
0x5A81, // [4] 45.00
0x6A6C, // [5] 56.25
0x7640, // [6] 67.50
0x7D89, // [7] 78.75
0x7FFF, // [8] 90.00
0x7D89, // [9] 78.75
0x7640, // [10] 67.50
0x6A6C, // [11] 56.25
0x5A81, // [12] 45.00
0x471C, // [13] 33.75
0x30FB, // [14] 22.50
0x18F8, // [15] 11.25
0x0000, // [16] 0
0xE708, // [17] -11.25
0xCF05, // [18] -22.50
0xB8E4, // [19] -33.75
0xA57F, // [20] -45.00
0x9594, // [21] -56.25
0x89C0, // [22] -67.50
0x8277, // [23] -78.75
0x8000, // [24] -90.00
0x8277, // [25] -78.75
0x89C0, // [26] -67.50
0x9594, // [27] -56.25
0xA57F, // [28] -45.00
0xB8E4, // [29] -33.75
0xCF05, // [30] -22.50
0xE708, // [31] -11.25
0x0000, // [32] 0
0x18F8, // [33] 11.25
0x30FB, // [34] 22.50
0x471C, // [35] 33.75
0x5A81, // [36] 45.00
0x6A6C, // [37] 56.25
0x7640, // [38] 67.50
0x7D89 // [39] 78.75
};
Could someone explain to me the idea behind the shift, xor and mod operations in the first line of code?
How i could create my look up table "QuadratureTable" for [0,...,200,...,0,...,-200,...,0], sinus waveform ?
Best regards,
S.Tarik