Closed Palomino34 closed 2 years ago
This solution will help for now.
private static double ReadDeviceTemperature() { channel = controller.OpenChannel(SC20260.Adc.Controller3.InternalTemperatureSensor); // GHI added
int disable_val = Marshal.ReadInt32(enable_reg);
int enable_val = disable_val |= (1 << 23);
Marshal.WriteInt32(enable_reg, enable_val);
var v = channel.ReadValue() * 1.0;
var ts1 = Marshal.ReadInt32(ts_reg1);
var ts2 = Marshal.ReadInt32(ts_reg2);
Marshal.WriteInt32(enable_reg, disable_val);
var t1 = (110 - 30) * 1.0;
var t2 = (ts2 - ts1) * 1.0;
var t3 = (v - ts1) * 1.0;
double temperature = t1 / t2 * t3 + 30;
Debug.WriteLine("T = " + temperature + " Celsius");
channel.Dispose(); // GHI added
return temperature;
}
Done. Correct analog touch then this issue gone.