123
Fork of LG by
Diff: DeviceDither.c
- Revision:
- 177:672ef279c8e0
- Parent:
- 174:0f86eedd511c
- Child:
- 182:2bd8ec44998f
diff -r c718d402410d -r 672ef279c8e0 DeviceDither.c --- a/DeviceDither.c Thu Jun 30 09:04:22 2016 +0000 +++ b/DeviceDither.c Sun Jul 03 13:40:48 2016 +0000 @@ -330,8 +330,8 @@ void ditherProcessPhase(void) { //Raw phase -1...+1 in 16.16 format - if (device.counters.dither.state.frequency > 0) {//0...+2500 in 32.0 format (1MHz/400Hz) - device.dither.detector.state.phase = device.dither.detector.state.sum / device.counters.dither.state.frequency; //-1...+1 in 16.16 format + if (device.counters.dither.state.amplitude > 0) {//0...+2500 in 32.0 format (1MHz/400Hz) + device.dither.detector.state.phase = device.dither.detector.state.sum / device.counters.dither.state.amplitude; //-1...+1 in 16.16 format } else { device.dither.detector.state.phase = 0; } @@ -360,7 +360,7 @@ //Frequency = device.counters.state.frequency * device.dither.frequency.state.frequency / 2; // 500 * 400Hz (0x01900000) / 2 / 1000 = 100kHz (0x00640000) // 500 * 0x19000000 / 2000 / 16 = 100kHz = 0x00640000 - device.dither.amplitude.state.frequency = (device.counters.dither.state.frequency * ((device.dither.frequency.state.frequency << 4) / 2000)) >> 4; + device.dither.amplitude.state.frequency = (device.counters.dither.state.amplitude * ((device.dither.frequency.state.frequency << 4) / 2000)) >> 4; device.dither.amplitude.state.error = device.dither.amplitude.state.frequency - device.dither.amplitude.state.reference; //0...200kHz 16.16 format device.dither.amplitude.state.correction = (device.dither.amplitude.state.scale * ditherPulseCorrection(device.dither.amplitude.state.error)) >> 16;