Dear TI,
I am in trouble with ADS1258 Pulse Convert CMD and Register Read Cmd. Maybe I am using the commands incorrectly.
I would like to read the Internal Values of ADS1258-EVM, so I have Enabled all relevant bits in SYSREG and disabled all MIXDIF and MUXSG bits. All these registers are read back in order to check the register values again.
To read the Channel Values here is my method:
private readonly byte[] _pulseConvertCmd = new byte[] { 0x80 }; public void Test() { SpiInterface.Write(_pulseConvertCmd); channelData = RegisterDataRead(Status.ChannelID.OFFSET); Offset = channelData.GetOffset(); } public ChannelData RegisterDataRead(Status.ChannelID channelID) { byte maskbit = 0x80; byte[] readBuff = new byte[5]; byte chID = 0; bool isSuccess = false; int i = 0; byte[] tries = new byte[StatusByteMaxPollInteration]; StopWatch sw = new StopWatch(); for (i = 0; i < StatusByteMaxPollInteration; i++) { SpiInterface.WriteRead(_registerDataRead, readBuff); chID = readBuff[1]; chID <<= 3; chID >>= 3; tries[i] = readBuff[1];
Debug.Print(readBuff[1].ToString());
// True if NEW bit arrive and ChannelID is proper //if ((chID == (byte)channelID) && (((byte)(maskbit & readBuff[1])) == maskbit)) { isSuccess = true; break; } // Check only ChannelID if (chID == (byte)channelID) { isSuccess = true; break; } } if (!isSuccess) { throw new System.ArgumentException("Unable to Read proper value from SPI"); } prev = readBuff[1]; // Create response array byte[] dataCode = new byte[3]; int j = 0; for (i = 2; i < readBuff.Length; i++) { dataCode[j] = readBuff[i]; j++; } Status statusByte = new Status(readBuff[1]); Debug.Print("Power Supply: " + statusByte.SUPPLY.ToString()); ChannelData chData = new ChannelData(dataCode, statusByte); return chData; }
As you can see, after then I execute the PulseConvertCmd I am polling the NEW bit and ChannelID bits in Status Byte to catch the incoming valid data. Somehow the NEW bit missing and invalid values appear
Here is my stop condition:
// Check only ChannelID if (chID == (byte)channelID) { isSuccess = true; break; }
instead of this one:
// True if NEW bit arrive and ChannelID is proper //if ((chID == (byte)channelID) && (((byte)(maskbit & readBuff[1])) == maskbit)) { isSuccess = true; break; }
And here is my output (Status Byte in decimal representation):
Reading Offset Status Byte: 29 - Remaining StatusByte value (old val.) Status Byte: 0 - ??? what is this? Status Byte: 24 - Valid ChannelID for Offset Status Byte: 24 Status Byte: 24 Status Byte: 24 Status Byte: 24 Status Byte: 24 Status Byte: 24 Status Byte: 24 Power Supply: False Reading VCC Status Byte: 24 - Last ChannelID (for Offset) Status Byte: 181 - New bit OK, but Channel ID does not match Status Byte: 26 - Valid ChannelID for VCC Status Byte: 26 Status Byte: 26 Status Byte: 26 Status Byte: 26 Status Byte: 26 Status Byte: 26 Status Byte: 26 Power Supply: False Reading Temp. Status Byte: 26 - Last Value Status Byte: 17 - ???? Unknown value Status Byte: 27 - Valid Channel ID for Temp Status Byte: 27 Status Byte: 27 Status Byte: 27 Status Byte: 27 Status Byte: 27 Status Byte: 27 Status Byte: 27 Power Supply: False Reading Gain Status Byte: 27 Status Byte: 224 - ??? what is this?? Status Byte: 56 - Status Byte: 28 Status Byte: 28 Status Byte: 28 Status Byte: 28 Status Byte: 28 Status Byte: 28 Status Byte: 28 Power Supply: False Reading Ref Status Byte: 28 Status Byte: 183 Status Byte: 29 Status Byte: 29 Status Byte: 29 Status Byte: 29 Status Byte: 29 Status Byte: 29 Status Byte: 29 Status Byte: 29 Power Supply: False ------------------------ Name: ADS1258 Offset: 0 Vcc: 4.5382410685221357 Temp: 21.835864921827724 Gain: 1.0007648468017578 Ref: 4.5664647420247393 -----------------------
My code has similar behavior if I am reading AI channels not for Internal channels. Unfortunately I don't have scope right now. Maybe I am using the ADS1258 Commands wrong?
Thank you for your kind reply.