Hi,
I have recently purchased one ADS 1158 EVM module from TI. I am trying to interface it with our ARM reference board. I was sucessfull in making the SPI communication to work. I am able to read/write adc registers. My current ADC configurations is,
Register values for address (00- 09) are: 0A,83,00,00,01,00,00,FF,00,9B.
CS,Start,SCLK,DIN,DOUT,DRDY are controlled or interfaced with arm processor.
S1,S2 - are in DAC, GND mode.
With this current configuration, I was expecting it to sample the channel 0 in single ended mode. As soon as I send high signal to start pin, I am able to received interrupts in DRDY pin. But, when I do register read or direct read of ADC data, I am getting some Junk values. I am not sure whether it is some kind of configuration issue or some coding issue.
I would appreciate any help in this issue. I am pasting my data receive code below. Please let me know if there are some flaws in my code.
// Code could be some what messy.. Its writen to check the functionality.. So, please let me know if some thing is not clear.
// Called on DRDY interrupt trigger.
uint32_t ADC_Direct_Read(SPI_TypeDef* SPI_PORT_NAME)
{
uint8_t rx_data=0;
// Status byte read
// Sending clock for reception.
ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);
while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);
// actual data reception.
rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);
// Sending the data via serial ( for debug pupose)
SendChar(HEX[((rx_data&0XF0)>>4)]);
SendChar(HEX[(rx_data&0X0F)]);
SendChar(',');
// MSB of data
ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);
while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);
rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);
// Sending the data via serial ( for debug pupose)
SendChar(HEX[((rx_data&0XF0)>>4)]);
SendChar(HEX[(rx_data&0X0F)]);
SendChar(',');
// LSB of data
ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);
while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);
rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);
// Sending the data via serial ( for debug pupose)
SendChar(HEX[((rx_data&0XF0)>>4)]);
SendChar(HEX[(rx_data&0X0F)]);
}
uint32_t ADC_Data_Read(SPI_TypeDef* SPI_PORT_NAME)
{
uint8_t rx_data,j1=0x00,dummy=0;
uint32_t rec_data=0;
// Toggle the cs pin.
CS_HIGH();
CS_LOW();
// Command to do register read
ADC_1158_Transmit_Data(SPI_PORT_NAME,0x30);
while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);
dummy=SPI_I2S_ReceiveData(SPI_PORT_NAME);
// Status byte reception
ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);
while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);
rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);
rec_data |= (rx_data & 0xFF);
rec_data = rec_data << 24;
// Data byte MSB reception
ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);
while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);
rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);
rec_data |= (rx_data & 0xFF);
rec_data = rec_data << 16;
// Data byte LSB reception.
ADC_1158_Transmit_Data(SPI_PORT_NAME,0xFF);
while (SPI_I2S_GetFlagStatus(SPI_PORT_NAME, SPI_I2S_FLAG_RXNE) == RESET);
rx_data=SPI_I2S_ReceiveData(SPI_PORT_NAME);
rec_data |= (rx_data & 0xFF);
return rec_data;
}
586,1-8 48%