This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/TM4C123GH6PZ: External ADC interface

Part Number: TM4C123GH6PZ


Tool/software: TI C/C++ Compiler

Hi,

I am interfacing TM4C123 with LTC2442 external ADC. I am facing an issue while reading the ADC values using delay. I am reading the ADC in 2 method. 

SSI configuration

void LTC2442_SPI_config(void)
{
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0);
	while(!SysCtlPeripheralReady(SYSCTL_PERIPH_SSI0));
/*The SSI0eperipheral is on Port A and pins 2,3,4 and 5.*/
	ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);  
/*configure the port  pins for clock,chipselect,receiver,transmitter*/
  ROM_GPIOPinConfigure(LTC2442_SPI_CLK);
//    ROM_GPIOPinConfigure(LTC2442_SPI_CS);  // Using the chip select externally so configure as output
  ROM_GPIOPinConfigure(LTC2442_SPI_RX);
  ROM_GPIOPinConfigure(LTC2442_SPI_TX);
//	   ROM_GPIOPinConfigure(GPIO_PIN_7);
	ROM_GPIOPinTypeGPIOOutput(GPIO_PORTA_BASE, GPIO_PIN_3);
  LTC2442_SPI_CS_HI;
  ROM_GPIOPinTypeGPIOInput(GPIO_PORTA_BASE, GPIO_PIN_7); //Busy status pin 
/* Configure the pin for SSI*/	
  ROM_GPIOPinTypeSSI(GPIO_PORTA_BASE, LTC2442_SPI_TX_PIN  | LTC2442_SPI_RX_PIN  | LTC2442_SPI_CLK_PIN);
/* Clock setting for SSI*/	
//	  SSIClockSourceSet(SSI0_BASE, SSI_CLOCK_SYSTEM);
  ROM_SSIConfigSetExpClk(SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 2000000, 16);
  ROM_SSIEnable(SSI0_BASE);	
}

first method

int LTC2442_ADC_OutputRead(unsigned int Channelnumber)
{
uint32_t TX[2] = {0};
uint32_t data =0;
int i=0;
float sum =0;
float ADC_Conv = 0.2980232416405;
//unsigned int channel_number = 0xB0000000; 
//uint32_t dataread, datastored;
		while(GPIOPinRead(GPIO_PORTA_BASE, LTC2442_SPI_BUSY_PIN));
    /* make cs pin to low after reading the adc data*/
		LTC2442_SPI_CS_LO;

while(GPIOPinRead(GPIO_PORTA_BASE, LTC2442_SPI_BUSY_PIN));
    /* make cs pin to low after reading the adc data*/
LTC2442_SPI_CS_LO;
//ADC_SPI_Rqst_pkt = LTC2442_ADC_SPIPktGen(ADC_Channel_No);   //Generate the Packet for the ADC Channel data request.
//ADC_SPI_Read_Pkt = LTC2442_ADC_Communication(ADC_SPI_Rqst_pkt);               //Dummy Read to set the next output channel
	
	switch(Channelnumber)
 {

  case 0:
  {
		
		for(i =0; i<2;i++)
		{
				for(ulindex = 0; ulindex < NUM_SSI_DATA; ulindex++)
        {
		        
		      	ROM_SSIDataPut(SSI0_BASE, ch0[ulindex]);	
					  while(ROM_SSIBusy(SSI0_BASE)){}
					  ROM_SSIDataGet(SSI0_BASE, &ulDataRx[ulindex]);           							
					  while(ROM_SSIBusy(SSI0_BASE)){}
			      Delay(100);	  //5 millisecond delay
				}
			}
           }
break;
}
LTC2442_SPI_CS_HI;

Method 2

unsigned int LTC2442_ADC_Communication(unsigned int ADC_SPI_Rqst_pkt)
{
volatile unsigned int Temp_Pkt = 0,ADC_SPI_Read_Pkt = 0,Tx_Temp_Buff = 0 ;
while(GPIOPinRead(GPIO_PORTA_BASE, LTC2442_SPI_BUSY_PIN));
    /* make cs pin to low after reading the adc data*/
LTC2442_SPI_CS_LO;

while(ROM_SSIBusy(SSI0_BASE)){}
	
Tx_Temp_Buff = ((ADC_SPI_Rqst_pkt>>16) & 0x0000ffff) ;
	
ROM_SSIDataPut(SSI0_BASE,Tx_Temp_Buff);
	
while(ROM_SSIBusy(SSI0_BASE)){}
	
ROM_SSIDataGet(SSI0_BASE, &Temp_Pkt);    
	
while(ROM_SSIBusy(SSI0_BASE)){}
	
ADC_SPI_Read_Pkt = 	Temp_Pkt ;
	
ADC_SPI_Read_Pkt =  ADC_SPI_Read_Pkt << 16 ;
	
Tx_Temp_Buff = (ADC_SPI_Rqst_pkt & 0x0000ffff) ;
	
ROM_SSIDataPut(SSI0_BASE,Tx_Temp_Buff);                            //Second 16 bit packet to DAC.
	
while(SSIBusy(SSI0_BASE)){}
	
ROM_SSIDataGet(SSI0_BASE,&Temp_Pkt);
	
while(SSIBusy(SSI0_BASE)){}
	
LTC2442_SPI_CS_HI;

ADC_SPI_Read_Pkt |= Temp_Pkt ;
	return ADC_SPI_Read_Pkt;
}

In first method I am putting delay and able to read data. If I am not putting delay it is not reading and  in method 2 reading data without delay.

Why delay is affecting data read.

I want to read constant voltage at the output of ADC.  When I am trying to read voltages are fluctuating  in microvolt range. I connected a constant voltage source at the input of ADC and read the ADC output, but the voltages are fluctuating in microvolt range.When taking average also the values are fluctuating only. Is there any way to reduce this fluctuation.

Thank you,

Alphy

  • Greetings,

    May I begin by noting that 'few here' have past complained in regard to 'µV' fluctuations!    

    You have chosen a (very) powerful 24 bit ADC - the ability of such a device to achieve its specifications - very much depends upon its implementation!    (and your understanding, acceptance & compliance w/such device's (considerable) demands!)    Some of these 'demands' follow:

    • Linear (perhaps now ADI) markets a dedicated 'Eval Board' for this device - any form of  'inexpert pcb' - or worse still - a 'breadboard' - has absolutely NO CHANCE!   You are silent as regards your ADC's physical implementation - which is of critical importance.    (although µV fluctuation - almost surely suggests that the Eval board is present)    How is your ADC IC mounted?
    • Assuming a proper Eval Board - how proper & stable is the power delivery to the ADC Eval Board?   Can you 'realistically' measure power delivery - to microVolts - at your ADC IC's power pins?
    • While you note 'µV fluctuations' - you don't provide the degree of such fluctuation.   Such may be critical - and is currently unknown.
    • How 'µV Constant/Stable' is your 'Constant Voltage Source' - which is being applied to your ADC's input.    Again - have you the ability to (really) measure this to 'µV' - especially 'during' the conversions?
    • How proper, precise & secure is the 'Common Ground Connection' between your ADC (assumed Eval Board) & your '4C123' (assumed Launchpad?)   

    As to your reported 'Delay Variances' - the ADC's spec reveals: "6.9Hz/200nVRMS to 3.5kHz/25µVRMS" - thus the conversion rate does indeed impact conversion resolution.    However it is suspected that the 'issues above' are the 'more likely suspects' of  'µV' fluctuations!  

    Keep in mind as well - that such, 'high number of  ADC conversion data bits are most often employed to, EXTEND DYNAMIC SIGNAL RANGE' (i.e. via the prevention or reduction of  'signal clipping') - and (not) to simply increase signal resolution.

    Twenty-Four bit ADCs are the province of 'Real PROs' - few here (to include this reporter) are (ever) likely to require (or achieve) such accuracy.   As stated - a 'Perfect Storm' of 'Near Perfect Implementation & Measurement Techniques' are required - to extract the 'full measurement power' of such a superb - yet demanding - device...

  • Hi,

      I'm not familiar with the the LTC device. One thing for you to check is if the device is indicating EOC=0 on the SDO output. I will suggest you use a scope to check if you are getting the expected data. Since you are using an external ADC, you will get better support from the device vendor directly if you think that the external ADC is giving fluctuating conversion outputs with an constant input voltage. 

      i also want to give you a heads up that I will be out of office starting tomorrow for a week with limited access to forum. If your issue cannot be resolved today I will advice you create a new thread so our support team can assist you. 

  • Hi,

    Thank you so much for your quick reply.

    Reply to your doubts are given below,

    1.We are not using evaluation kit ,the ADC is mounted on our customised PCB. That board made for our in-house application.That we need .001% accuracy at the output of ADC.

    2. I measured the voltage of the input source(battery) using a high precision multimeter  and the values are consistent. There is no fluctuation in input voltage.

    3. The values I am reading are, 1670036,1670031,1670028,1670033,1670035,1670039,1670040 and Speed/Resolution is 220nVRMS Noise at 13.8Hz Output Rate with simultaneous 50Hz/60Hz Rejection.

    Today also I tried to read the values and fluctuations are still there. Is there anything we can do on program to achieve more accuracy.

    Thank you,

    Alphy 

  • Thank you - your detail is (both) helpful & appreciated.

    You/your firm are 'beyond brave' and/or highly skilled in 'pcb layout art/science' or ...   (diplomacy blocks further description.)

    You should know that it is just past 06:00 (here in the US west-coast) - and today is a national holiday - although a 'working holiday' for my team.    (thus this response must be clipped/short - I can return after our 'ceremonial obligations' are completed - should this 'quick hit' not properly resolve.)

    Response now 'keyed' to your numerical listings:

    1. Again - our findings have 'proved' that almost always - 'Use of the vendor's produced/supplied Eval Board proves optimal.'    Even minor pcb layout,  'shortcomings or compromises' may degrade such a sensitive device's performance.    (No criticism is implied - this is a 'simple statement of fact.')   At the minimum - my team would 'purchase the Eval Board' - and then 'copy/appropriate' everything, 'Not tied down!'   (this 'modeling' done prior to our attempt at such a 'demanding pcb design.')    Even the number of pcb layers - and their geometry & overlaps - is likely to prove crucial...
    2. Once more - is your 'high precision multimeter' (really) 'up to this task?'    (note that precision indicates 'repeatability' - you are after 'accuracy' here.)   If we assume that your meter (a 'multi-meter' at that) is 'up to task' - have you made (and logged) a series of measurements - during the same time of your MCU accessed, device readings?   (watching your 'meter' for a few seconds is (not) sufficient.)
    3. Reviewing your readings - but for the first two - those are monotonically increasing.    Temperature change suffered by your ADC is the (usual) cause for such monotonic 'fluctuations.'    Unstated is:
      • How long your ADC has been powered prior to your 'reading harvest?'
      • How stable the temperature remains - at/around the ADC's location?    And of course - at the ADC device itself.
      • How (very) stable is the 'supply or reference' - which drives your ADC's signal input?

      Finally you note, "Speed/Resolution is 220nVRMS Noise at 13.8Hz Output Rate" - yet the ADC's spec lists, "6.9Hz/200nVRMS" - suggesting that the ADC's resolution should (instead) become 440nVRMS - don't you agree?

    It proves always useful to contact the device vendor - in the attempt to discover what the device's 'Normal & Customary' behavior and/or response - should be.    To me - minus 'all the facts' - what you observe seems (essentially) normal.    Good luck...

  • Hi Alphy,

      I hope cb1's comments are useful to you. Again, I don't really know what to help here other than to let the community members like cb1 sharing his valuable comments. You are using a third party component and we really have no experience with it. I will suggest you contact the component vendor directly to seek assistance.