Because of the holidays, TI E2E™ design support forum responses will be delayed from Dec. 25 through Jan. 2. Thank you for your patience.

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.

ADS1232: ADS1232 fixed output

Part Number: ADS1232
Other Parts Discussed in Thread: TMS320F2812,

Hi,

In a weigh scale project, I've encountered a strange problem. I've employed ADS1232, TMS320F2812 and SPI serial interface.

After each falling edge of DRDY, the data register is read, but it always is FFFFFF, independently of the input range,

sometimes 7FFFFF or 3FFFFF

use Weigh Scale Application schematic

my code:

use Spi Example:

include "DSP281x_Device.h"     // DSP281x Headerfile Include File
#include "DSP281x_Examples.h"   // DSP281x Examples Include File

// Prototype statements for functions found within this file.
// interrupt void ISRTimer2(void);
void delay_loop(void);
void spi_xmit(Uint16 a);
void spi_fifo_init(void);
void spi_init(void);
void error(void);
Uint16  Temp;
Uint16 sdata;  // send data
Uint16 rdata[3];  // received data



void main(void)
{
    Uint16 i=0;

   InitSysCtrl();
   InitGpio();  // Skipped for this example


   DINT;

  InitPieCtrl();

  IER = 0x0000;
   IFR = 0x0000;
   
  InitPieVectTable();

   spi_fifo_init();	  // Initialize the Spi FIFO
   spi_init();		  // init SPI
   InitXIntrupt();                 //Initialize external interrupt


       IER |= M_INT1 | M_INT6 
       EINT;                           // Enable INTM
       ERTM;                           // Enable DBGM

       GpioDataRegs.GPBDAT.bit.GPIOB0 = 1;//enable ADS1232

       GpioDataRegs.GPFDAT.all = 0x0000;
       Temp=0xF0;


  for(i=0;i<3;i++) rdata[i]=0;
   sdata = 0x0000;							
   for(;;)
   {    
   }
} 	



void spi_init()
{                                                //0000 0000 0000 01111
	SpiaRegs.SPICCR.all =0x0007;	             // Reset.7(enable),POLARITY=0, SPILBK =0 , rising edge, 8-bit char bits
	SpiaRegs.SPICTL.all =0x0006;    		     // OVERRUN int.4=0 PHASE.3=0 ,Enable master=1, normal phase,
	                                             // enable talk.1=1, and SPI int.0 disabled.
	SpiaRegs.SPIBRR =0x007F;									
    SpiaRegs.SPICCR.all =0x0087;		         // Relinquish SPI from Reset
    SpiaRegs.SPIPRI.bit.FREE = 1;                // Set so breakpoints don't disturb xmission
}

void spi_xmit(Uint16 a)
{
    SpiaRegs.SPITXBUF=a;
}    

void spi_fifo_init()										
{
    // Initialize SPI FIFO registers  //1110 0000 0100 0000
    SpiaRegs.SPIFFTX.all=0xE040;//SPIRST.15,SPIFFENA.14,TXFIFOrest.13 renable,
                                //TXFFST.12-8 ,TXFFINT.7, TXFFINT CLR.6, TXFFIENA.5,TXFFIL4-0
    SpiaRegs.SPIFFRX.all=0x204f;//RXFFOVF.15, RXFFOVF CLR.14, RXFIFOReset (Renable), RXFFST12-8
                                //RXFFINT, RXFFINT CLR, RXFFIENA.5, RXFFIL4-0

    SpiaRegs.SPIFFCT.all=0x0;   // FIFO transmit delay bits
}  

and XINT:

interrupt void  XINT2_ISR(void)
{
    // Insert ISR Code here
      Uint16 i=0;
      Temp^=0xC0;
      GpioDataRegs.GPFDAT.all = Temp;
      // Transmit data
      sdata=0xF0;
     for(i=0;i<3;i++)
    {
          spi_xmit(sdata<<8);
          // Wait until data is received
          while(SpiaRegs.SPIFFRX.bit.RXFFST !=1) { }
          // Check against sent data
          rdata[i] = SpiaRegs.SPIRXBUF ;
          sdata++;
      }

  • Hi Nima,

    Could you try reposting the schematic as the image did not come through. You said that you are not initializing the GPIO, but if you are using the GPIO to control the ADS1232, then you cannot allow a floating input pin on the ADS1232.  The ADS1232 is a pin controlled device and all control signals must be tied high or low.

    Best regards,

    Bob B

  • Hi Bob,

    I am grateful for your guidance

    The tasks you mentioned were checked and the output increased proportionally to the input

    1) Why is the output in the form of about 0x3fc07, even though the input is 0V? Also a lot of changes?

    2) What should I do to increase measurement accuracy? (hardware and software)


    In the your code ADS1232ref,how to convert hex data to volts?

    interrupt (PORT2_VECTOR) ads1232_isr(void)
    {
    	u8 *cptr=(u8 *)(&_code);
    
    	// disable int before shifting
    	DRDYIEL();
    
    	// get 3 bytes
    	U0TXBUF=0;
    	while(!(IFG1&URXIFG0));
    	cptr[2]=U0RXBUF;
    
    	U0TXBUF=0;
    	while(!(IFG1&URXIFG0));
    	cptr[1]=U0RXBUF;
    
    	U0TXBUF=0;
    	while(!(IFG1&URXIFG0));
    	cptr[0]=U0RXBUF;
    
    	if (_flags.cal) {
    		SCLKOUTL();
    		SCLKSELL();
    		SCLKOUTH();
    		SCLKOUTL();
    		SCLKOUTH();
    		SCLKOUTL();
    		SCLKSELH();
    	} else {
    		// sign-extend
    		cptr[3]=(cptr[2]&0x80)?0xff:0;
    #ifdef ADS1230
    		_code=_code>>4;
    #endif
    	}
    	// clear and reenable int
    	DRDYIFGL();
    	DRDYIEH();
    
    	// signal tasks
    	if (_flags.cal) // don't output data on cal
    		_flags.cal=0;
    	else {
    		_flags.newdata=1;
    		if (_monitor) {
    			vTaskResume(_monitor);
    			taskYIELD();
    		}
    	}
    }
    

    Can you provide pseudo-code for this conversion?

  • Hi Nima,

    I still don't have your schematic, so it is difficult for me to speculate why you have what appears as a large offset.  On power-up, did you make sure that PDWN pin was held low for at least 10us after the supplies have reached nominal voltage?  And did you initiate the self-offset calibration?  Both of these are very important.  It is also a good idea to pulse the PDWN pin after power-up if you have this pin connected to a GPIO to make sure the ADS1232 has started properly with the correct gain coefficient.  All digital pins should be connected somewhere and should not be floating.  It is ok to float analog input pins.

    The code segment you have shown from the ADS1232REF is the interrupt routine for capturing data only.  You should do as little as possible in the service routine especially when using a slow micro like what exists on the ADS1232REF.  

    The code to volt conversion is in the display.c file and follow the process of finding the value of one code (LSB) which is shown in Table 8, which is shown as (+0.5Vref/Gain)/(2^23-1).  Take the result for one LSB and multiply times the conversion value received.  The actual C code used is shown below and is altered by using a slightly different LSB calculation (Vref/Gain)/(2^24).

    float code2volt(float c)
    {
    
        return (c/(1L<<24))*(disp_vref/ads1232_get_gain());
    
    }

    As the ADS1232REF can have multiple configurations, the variable display_vref and the return value from ads1232_get_gain() could be set to a fixed value in your code.  For example, if the reference was set to 5V and the gain set to 128 the return value would become:

    float code2volt(float c)
    {
    
        return (c/(1L<<24))*(5.0/128);
    
    }

    Obviously there are many other approaches to accomplish the same result in C.

    Best regards,

    Bob B