Hi to all,
I am working with the LMP90100 multi-channel ADC. I do the inferface with pic controller communication is working fine i am getting the default values from register and Displaying in LCD giving the exect values mention in the datasheet but when i am trying to get/read the value from the ADC register we are getting the erratic values.
please help us out where i doing wrong below is my program :-
void main()
{
unsigned char Cont=0,port_data=0;
MCU_Init();
Int_Lcoal_Variable=0;
Lcd_Out(2,1,"Testing");
Spi_Init();
Delay_100ms();
LM_90100_Init();
//Power Config
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_PWRCN_REG,0); //Active Mode
//AUXCN
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_ADC_AUXCN_REG,0x0A); //Config AuxChannel
//Channel Config
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_CH0_CONFIG_REG,0x41); //Config Channel Zero
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_CH1_CONFIG_REG,0x41); //Config Channel One
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_BGCALCN_REG,0x00); //Confif TI_LMP90100_BGCALCN_REG
//Channel Input
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_CH0_INPUTCN_REG,0x41); //Confif TI_LMP90100_CH0_INPUTCN_REG
//LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_CH1_INPUTCN_REG,0x41);
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_ADC_RESTART_REG,1); //REset the ADC Register
while(1)
{
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_CH_SCAN_REG,0x00);
LM_90100_Spi_Writing_Address_Data(TI_LMP90100_CH_STS_REG,LM90100_Read_Ptr,1,SPI_READ);
//Storing the CH_STS_REG Value to the LM90100_Read_Ptr
if(*LM90100_Read_Ptr<0xff) //Checking the CH_STS_REG Status
{
LM_90100_Spi_Writing_Address_Data(TI_LMP90100_ADC_DOUT2_REG,LM90100_Read_Ptr,3,SPI_READ);
Display_Int2Float(1,1,*LM90100_Read_Ptr,_One_Degree,0); ///Reading the Upper register value
Display_Int2Float(2,1,*(LM90100_Read_Ptr+1),_One_Degree,0); ///Reading the Middle register value
Display_Int2Float(2,10,*(LM90100_Read_Ptr+2),_One_Degree,0); ///Reading the Lower register value
Display_Int2Float(1,10,Cont++,_One_Degree,0); //Just to know where the programm is comming to this while loop or not.
port_data=~port_data;
LM90100_Spi_Read_Write_Single_Value(TI_LMP90100_GPIO_DAT_REG,port_data); // Complimenting the GPIO ports this is also WORKING we had testing using the multimeter.
Delay_ms(1000);
}
}
}
Thanks & Regards