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.

RF430FRL152HEVM ADC Question: ADC0 Only Ouputs 1FF0

Hi,

So I'm looking to automate an ADC reading upon the device's startup by inserting some code into the DigitalSensorInit from the SensorHub_Project CCS project (there's a few things that shouldn't be looped through, but I just wanna get it working before going after that :p ). Essentially, I want to sample ADC0 every second and store it into FRAM (adc_register is a 64 element 16-bit array, and read_time is 64). I've been trying to test this by connecting ADC0 to a small DC source, and no matter what value I use (I've tried 0-0.7V), the data I read back from the FRAM for each sample is 1FF0. I thought the setup below would suffice, but something else is definitely wrong. What would be an issue with the setup below?

Thanks!

void DigitalSensorInit()
{
    //ROM sets P1OUT = 0x0F, this then consumes some current
    P1OUT = 0x00; // needed to reduce power consumption on RF430FRL152H EVM, since P1.3 is connected to a 2.2K Ohm resistor on the EVM to ground

    P1DIR &= ~MASTER_SLAVE_SELECT; // check if digital sensor mode is selected
    if (P1IN & MASTER_SLAVE_SELECT)
    {
        //P1DIR &= ~MASTER_SLAVE_SELECT;  //host controller mode selected, exit
        return;
    }
    
    /* For custom digital sensor initialization, keep the previous code as is and change the following as needed.*/

    // Configure P1.0 and P1.1 pins for I2C mode
    PORT_I2C_SEL0 |= SCL + SDA;
    PORT_I2C_SEL1 &= ~(SCL + SDA);

    // configure eUSCI for I2C
    UCB0CTL1 |= UCSWRST;	               // Software reset enabled
    UCB0CTLW0 |= UCMODE_3  + UCMST + UCSYNC + UCTR;  	// I2C mode, Master mode, sync, transmitter
    UCB0CTLW0 |= UCSSEL_2;                           	// select SMCLK at 2MHz
    UCB0BRW = 20;                                    	// 2Mhz / 20 = 100kHz
    UCB0I2CSA  = 0x0048;		// slave address of device
    UCB0CTL1  &= ~UCSWRST;                       	// exit reset mode

	u08_t i;

    for (i = 0; i < read_time; i++){
    	SD14CTL0 |= SD14EN;
    	SD14CTL0 |= SD14IE;
		SD14CTL0 |= VIRTGND;								// use avss instead of svss
		SD14CTL0 |= SD14SGL;								
		SD14CTL1 |= SD14INTDLY1;
		SD14CTL0 |= SD14SC;       			//Start conversion of ADC, enable ADC

		while( !(SD14CTL0_H & ADC_SD14IFG_8BIT) ); 			//wait for conversion to finish (for single conversion), ADC_SD14IFG_8BIT = 0x02
adc_register[i] = SD14MEM0; SD14CTL0 &= ~SD14SC; //Stop conversion 
SD14CTL0 &= ~SD14EN; //disable ADC 
__delay_cycles(2000000); 
} 
return; 
}

  • Also to clarify, I removed the R16 (0 ohm jumper) resistor so the rest of the circuitry would not interfere. Is there any other info that I could give that may be helpful?
  • One thing is that you should do is instead of setting the SD14IE clear it:

    Anthony Rogers said:
    SD14CTL0 |= SD14IE;

    The reason is that without this change the ROM SD14 Interrupt Service routine will run after the conversion which may change things a bit.  For instance it will read the SD14MEM0 register before you can.  So by clearing that bit will prevent that from happening.  You should still be able to poll for the SD14IFG flag.

  • Thank you for the response! That makes sense; I could see that being bad for a single conversion method. I gave it a whirl and no luck. Currently, the section looks like:

    for (i = 0; i < read_time; i++){
    	        SD14CTL0 |= SD14EN;
    	        SD14CTL0 &= ~SD14IE;
    	        SD14CTL0 |= VIRTGND;                                // use avss instead of svss
    	        SD14CTL0 |= SD14SGL;
    	        SD14CTL1 |= SD14INTDLY1;
    	        SD14CTL0 |= SD14SC;                 //Start conversion of ADC, enable ADC
    
    	        while( !(SD14CTL0_H & ADC_SD14IFG_8BIT) );          //wait for conversion to finish
    		adc_register[i] = SD14MEM0;
    		SD14CTL0 &= ~SD14SC; //Stop conversion
    		SD14CTL0 &= ~SD14EN; //disable ADC
    	        __delay_cycles(2000000);
    	}
    

    I also tried switching the order and I also tried using continuous conversions as well, but unfortunately I still get 1FF0 for my values. I also tried sampling the internal temperature sensor by using:

    "SD14CTL1 |= SD14INCH0; // use internal temp sensor"

    and I get the same 1FF0. What else do you think could be wrong?

  • There is atleast one problem in how you are setting up the SD14. One of them is the timing. SD14 needs to be clocked by ACLK and at 2kHz.

    There is an example project that does sample the SD14 at power-up. Please find the link to it in this thread:
    e2e.ti.com/.../1483748
    It was developed for an RF only ROM support project. However if you don't choose to use it, look at the DeviceInit function on how the ACLK is setup and the SD14 setup function as well.
  • Ah, I saw that while searching around and tried a few things from it previously, but I didn't take the ADC clocking into consideration... I bet that's the problem. I'll mess around with it and see if that fixes it, thank you!