SI2C Module and a CAT5171 Digipot Problem
Posted: Thu Apr 28, 2016 6:19 pm
I'm using an On Semiconductor CAT5171 digipot with the SI2C module and having a strange problem. When I red back the values I write to it, the returned value is half of the value I set. I don't know if the set value is incorrect, or the returned value.
I'm reading the register just as a way to determine if this auxiliary board is in the circuit.
The code is pretty simple and there's little chance for error, so I'm wondering if it's a problem is the SI2C module.
I use this code to set the value. Val2 is the level it's set to. Val1 is the instruction byte, which turns the chip on and DOES NOT set the wiper to mid-range.
And here's the subroutine where I'm reading the value back.
There's not much to go wrong here.
The micro is an 18F25K22.
Any suggestions?
I'm reading the register just as a way to determine if this auxiliary board is in the circuit.
The code is pretty simple and there's little chance for error, so I'm wondering if it's a problem is the SI2C module.
I use this code to set the value. Val2 is the level it's set to. Val1 is the instruction byte, which turns the chip on and DOES NOT set the wiper to mid-range.
Code: Select all
'setting the CAT5171
Val1 = %00000000 'not mid-scale, normal ops
I2CDevice = 88
SI2C.Start
SI2C.WriteByte(I2CDevice)
SI2C.Acknowledge(I2C_ACKNOWLEDGE)
SI2C.WriteByte(Val1)
SI2C.Acknowledge(I2C_ACKNOWLEDGE)
SI2C.WriteByte(Val2)
SI2C.Acknowledge(I2C_ACKNOWLEDGE)
SI2C.Stop
Code: Select all
Sub DetectBoard()
dim ReturnedValue as byte
I2CDevice = 88 +1 ' for read
SI2C.Start
SI2C.WriteByte(I2CDevice)
SI2C.Acknowledge(I2C_ACKNOWLEDGE)
ReturnedValue = SI2C.ReadByte
SI2C.Acknowledge(I2C_NOT_ACKNOWLEDGE)
SI2C.Stop
If ReturnedValue = 0 Then
Audio_Board_Installed = false
Else
Audio_Board_Installed = true
End If
UART.Write (DecToStr(returnedvalue), 13, 10)
End Sub
The micro is an 18F25K22.
Any suggestions?