Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

ADS 1148 not working

$
0
0

Hi All

I am trying to configure ADS 1148 but I followed following steps

1. at the start

    START low

    RESET low

   CS         high

   clk        low

delay for 2^16 cycles

2.  give SDATAC command

3. give WREG command

   write 0E registers

4. give RDATA camand

5. give NOP read MSB

6. give NOP read LSB

but what I read is only garbage which is unaffected by any temprature change at PT 100.

I am using LM 3s9b96when I try to read the registers i get any random values and not what i had written into it.

I am posting here my code.

        T_f32 ReadTemp1148(void)
{
 T_u8 ulindex;

 T_f32 f32_RecivedTemp =0.0;
  //
  //On POWER ON
  //
  GPIOPinWrite(GPIO_PORTC_BASE, ADC_START,ADC_START);
  GPIOPinWrite(GPIO_PORTD_BASE, ADC_RESET,ADC_RESET);

  GPIOPinWrite(GPIO_PORTG_BASE, SSI_CS, 0);
  GPIOPinWrite(GPIO_PORTA_BASE, ADC_Tx,0x01);
//  GPIOPinWrite(GPIO_PORTA_BASE, ADC_CLK,0);
 
  SysCtlDelay(21846); 2^16 cycle delay

 
  GPIOPinWrite(GPIO_PORTC_BASE, ADC_START,ADC_START);
  GPIOPinWrite(GPIO_PORTD_BASE, ADC_RESET,ADC_RESET);

  GPIOPinWrite(GPIO_PORTG_BASE, SSI_CS, 0);

  SSIDataPut(SSI0_BASE, CMD_SDATAC);  
   
    GPIOPinWrite(GPIO_PORTC_BASE, ADC_START,ADC_START);
    GPIOPinWrite(GPIO_PORTD_BASE, ADC_RESET,ADC_RESET);

    GPIOPinWrite(GPIO_PORTG_BASE, SSI_CS, 0);
     while(SSIDataGetNonBlocking(SSI0_BASE, &Dummy))
   {
        
        UARTprintf("\n dummy = %d", Dummy);
        // Read until there is no more data to read.
   }
 
   

    SSIDataPut(SSI0_BASE, CMD_WREG);//Give Command write to reg WREG, first command Byte 0100 rrrr  where rrrr- address of the first register to be written
      SSIDataPut(SSI0_BASE, 0x00);    //Second command Byte 0000 nnnn where nnnn is number of registers to be written - 1
    SSIDataPut(SSI0_BASE, VAL_MUX0_OVEN);
    SSIDataPut(SSI0_BASE, VAL_VBIAS_OVEN);
    SSIDataPut(SSI0_BASE, VAL_MUX1_NORMAL);
    SSIDataPut(SSI0_BASE, VAL_SYS0);
        SSIDataPut(SSI0_BASE, VAL_OFC0);
    SSIDataPut(SSI0_BASE, VAL_OFC1);
    SSIDataPut(SSI0_BASE, VAL_OFC2);
    SSIDataPut(SSI0_BASE, VAL_FSC0);
    SSIDataPut(SSI0_BASE, VAL_FSC1);
    SSIDataPut(SSI0_BASE, VAL_FSC2 );
    SSIDataPut(SSI0_BASE, VAL_IDAC0_750 );
    SSIDataPut(SSI0_BASE, VAL_IDAC1_OVEN);
    SSIDataPut(SSI0_BASE, VAL_GPIOCFG);
    SSIDataPut(SSI0_BASE, VAL_GPIODIR);
    SSIDataPut(SSI0_BASE, VAL_GPIODAT);

   SysCtlDelay(20);
   GPIOPinWrite(GPIO_PORTG_BASE, SSI_CS, 0);

  SSIDataPut(SSI0_BASE, CMD_RREG);
  SSIDataPut(SSI0_BASE, 0x0E);
   
  while(SSIDataGetNonBlocking(SSI0_BASE, &Dummy))
   {
        
        UARTprintf("\n while RREG = %d", Dummy);
        // Read until there is no more data to read.
   }

    

   //Read DATA /DRDYn pin
  while(b_ChkDRDY != false)
  {
   //
   UARTprintf("\n inside while %d", b_ChkDRDY);
   //
   b_ChkDRDY = GPIOPinRead(GPIO_PORTA_BASE,ADC_RX);
   //
   
  }

   

   //
  UARTprintf("\nB4 if %d", b_ChkDRDY);
   //
   //If DRDY goes low to indicate Conversion complete Read data
   //
  if(b_ChkDRDY == false)
    {
  GPIOPinWrite(GPIO_PORTC_BASE, ADC_START,ADC_START);
  GPIOPinWrite(GPIO_PORTD_BASE, ADC_RESET,ADC_RESET);

  GPIOPinWrite(GPIO_PORTG_BASE, SSI_CS, 0);
  SSIDataPut(SSI0_BASE, CMD_RDATAC);
 
  UARTprintf("\nSSIDataGet");

  SysCtlDelay(20);

  SSIDataPut(SSI0_BASE, CMD_NOP);


  SSIDataGet(SSI0_BASE, &u32_ADCDataBuffer[0]); //Read data MSB
  UARTprintf("\n%d", u32_ADCDataBuffer[0]);
  f32_RecivedTemp = u32_ADCDataBuffer[0];
  SSIDataPut(SSI0_BASE, CMD_NOP);
  SSIDataGet(SSI0_BASE, &u32_ADCDataBuffer[1]); //Read Data LSB
  UARTprintf("\n%d", u32_ADCDataBuffer[1]);
  f32_RecivedTemp = u32_ADCDataBuffer[1];
  }
 else
  {
  UARTprintf("\n%d else", b_ChkDRDY);
  }
  GPIOPinWrite(GPIO_PORTC_BASE, ADC_START,ADC_START);  // Make START low

  GPIOPinWrite(GPIO_PORTG_BASE, SSI_CS, 0);
  return(f32_RecivedTemp );
}

Best regards

Nishant


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>