Post Go back to editing

# Ltc2439-1 in SPI communication data output is high first out or low first out?

Read data is 0XF4,0X53,0XFE, how to parse?

help
[edited by: ljln119 at 3:25 AM (GMT 0) on 14 Jan 2020]
Parents
Children
• When B0 is sent, the received data is hexadecimal 88,40, F0.Actual channel B0= 0.260v.When sending B1, the received data is hexadecimal E8,A7,FC, and the actual channel B1=2.495V.The Numbers don't match.Is the received data high or low?How do I parse data?Thank you very much!

• This is the waveform that sends B0,

• The waveform received after sending B0

• Looking at the oscilloscope photo, I decoded 22,03,9F. If you look at SDO at the rising edge of the first two SCK pulses you will see they are both zero. At the next rising edge SDO is high and at the 4th rising edge SDO is again zero. 0010 is a hex 2. Continue decoding in this manner and you will get 22,03,9F.

Next you have to strip out the extra bits. You have 24bits and the ADC only outputs 16 actual data bits. The first 3 bits (EOC DMY and SIG) combined with the MSB (B15) are used to determine over-range. You can look at Table2 of the data sheet and see that 0010 indicates that the data is greater than 0 and less than Vref/2.

Bits 15 through 0 are the data you want. The five 1s after Bit15 can be ignored.

Parsing B15-B0 yields 10,1C in hex. This is 4124 in decimal. 4124/32768 * Vref/2 should equal your input voltage. You haven't stated the reference voltage but I will assume it is 5V which indicates an input voltage of 0.314V. This is close to your stated input voltage of 0.26V but the ADC should be much more accurate than that. Do you have a filter at the analog input? Actually, it would be a good idea if you provided your schematic and even a photo of your circuit if that is possible.

• void Write_SPI_Byte(unsigned char SPI_Byte)
{
SPI_CS(0);//片选
bit_mask = 0x80; // MSB order first
for (k = 0; k < 8; k++)
{
if(SPI_Byte & bit_mask) // load bit value
SPI_SIMO(1);
else
SPI_SIMO(0);
SPI_CLK(1); // clock it out
bit_mask /= 2; // next bit (the "/= 2" provides necessary delay over ">> 1")
SPI_CLK(0); // clock reset
}
SPI_CS(1);
}

//--------------------------------------------------

{
unsigned char i;
unsigned char SPI_Byte=0;
//SPI_CS(0);//片选
for (i = 0x01; i != 0; i <<= 1) //低位在前，逐位读取
{
if (SPI_SOMI != 0) //首先读取此时的IO引脚，并设置dat中的对应位
{
SPI_Byte |= i;
}
SPI_CLK(1); //然后拉高时钟
SPI_CLK(0); //再拉低时钟，完成一个位的操作
}
return SPI_Byte; //最后返回读到的字节数据
}

{
unsigned char Data[3]={0,0,0};//从SPI总线读取的数据，Data[0]是最高位
unsigned char i,j;

Write_SPI_Byte(0XB0);
delay_ms(200);
SPI_CS(0);//片选
SPI_CS(1);//片选
delay_ms(200);
Write_SPI_Byte(0XB1);
delay_ms(200);
SPI_CS(0);//片选
SPI_CS(1);//片选
}

Is there something wrong with my SPI program? Please give me the guidance. Thank you!

• I am not a programmer. It appears that your program is correctly telling the ADC what to do but it is not correctly deciphering the data that comes from the ADC. Did my description of how to decode the data from the ADC make sense to you? Can you use that to determine where your program is misinterpreting the ADC data?

Looking at your schematic, I think I understand why the ADC reading is not correct. You have a large filter on the CH0-CH11 inputs. This filter will not settle in the time allowed. I suggest you put the same filter on the COM pin or reduce the size of the filter.

• Thank you very much for your reply, the analytic method you provided is very useful!In the schematic diagram, the input terminal of ltc2439-1 is the partial voltage circuit. After deletion, the program of reading data at the same time has been modified.Ask: what is the voltage range of the input terminal of ltc2439-1? At present, 0.522v is input and MCU is read correctly.Input 5.0v, MCU reading value is 30,00,1f, data parsing is 2500, why?My circuit reference voltage is 5V.

• With COM = 0V, the input voltage range for a single-ended signal is 0V to Vref/2. With a 5V reference that means 0V to 2.5V.

• Thank you very much!Another question, I set the maximum charging current 2A, and the charging cut-off voltage 2.6v. Why is the charging current 1.7a when the charging voltage is 2.2v? As the voltage rises, the current is gradually decreasing?I understand that the working mode of ltc2439-1 is constant current 2A first, and the current gradually decreases after reaching the voltage of 2.6v until the charging is completed.Why not me?

• I do not understand your question. What are the charging current and cut-off voltage you are referring to? This sounds more like a switching regulator than an ADC.

• Sorry, I misremembered! It's the BQ24650 chip.

• Ltc2439-1 chip, internal shock MCU communicate with other SPI, MCU send channel command after waiting for how long to start reading?

After MCU sends the read command, how long will it take for ltc2439-1 to be converted and the MCU to read the data?

See Table4 for specification, conversion time 147ms.

At present, I send the channel command with a delay of 200ms, then send the read command with a delay of 200ms, then read the data.

Why is this chip communicating so slowly?The display speed of the touch screen is too slow to refresh.

It would be nice to have an ltc2439-1 communicator example available!