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.

cc4306137 internal temp and battery level

Other Parts Discussed in Thread: CC430F6137, CC-DEBUGGER

Is there sample code to TX and RX the internal temp sensor and battery level for the emcc430f6137?  I found:

cc430x613x_adc12_10.c         ADC12, Sample A10 Temp and Convert to oC and oF,  but this isnt what i am looking for

James

//******************************************************************************
//  CC430F613x Demo - ADC12_A, Sample A10 Temp and Convert to oC and oF
//
//  Description: A single sample is made on A10 with reference to internal
//  1.5V Vref. Software sets ADC12SC to start sample and conversion - ADC12SC
//  automatically cleared at EOC. ADC12 internal oscillator times sample
//  and conversion. In Mainloop MSP430 waits in LPM4 to save power until
//  ADC10 conversion complete, ADC12_ISR will force exit from any LPMx in
//  Mainloop on reti.
//  ACLK = n/a, MCLK = SMCLK = default DCO ~ 1.045MHz, ADC12CLK = ADC12OSC
//
//  Uncalibrated temperature measured from device to devive will vary due to
//  slope and offset variance from device to device - please see datasheet.
//
//                CC430F6137
//             -----------------
//         /|\|              XIN|-
//          | |                 |
//          --|RST          XOUT|-
//            |                 |
//            |A10              |
//
//   M. Morales
//   Texas Instruments Inc.
//   April 2009
//   Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include "cc430x613x.h"

volatile long temp;
volatile long IntDegF;
volatile long IntDegC;

void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
 
  /* Initialize the shared reference module */
  REFCTL0 |= REFMSTR + REFVSEL_0 + REFON;    // Enable internal 1.5V reference
 
  /* Initialize ADC12_A */
  ADC12CTL0 = ADC12SHT0_8 + ADC12ON;  // Set sample time
  ADC12CTL1 = ADC12SHP;                     // Enable sample timer
  ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_10;  // ADC input ch A10 => temp sense
  ADC12IE = 0x001;                          // ADC_IFG upon conv result-ADCMEMO
 
  __delay_cycles(75);                       // 35us delay to allow Ref to settle
                                            // based on default DCO frequency.
                                            // See Datasheet for typical settle
                                            // time.
  ADC12CTL0 |= ADC12ENC;

  while(1)
  {
    ADC12CTL0 |= ADC12SC;                   // Sampling and conversion start

    __bis_SR_register(LPM4_bits + GIE);     // LPM4 with interrupts enabled
    __no_operation();

    // Temperature in Celsius
    // ((A10/4096*1500mV) - 894mV)*(1/3.66mV) = (A10/4096*410) - 244
    // = (A10 - 2438) * (410 / 4096)
    IntDegC = ((temp - 2438) * 410) / 4096;

    // Temperature in Fahrenheit
    // ((A10/4096*1500mV) - 829mV)*(1/2.033mV) = (A10/4096*738) - 408
    // = (A10 - 2264) * (738 / 4096)
    IntDegF = ((temp - 2264) * 738) / 4096;
   
    __no_operation();                       // SET BREAKPOINT HERE
  }
}

#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
{
  switch(__even_in_range(ADC12IV,34))
  {
  case  0: break;                           // Vector  0:  No interrupt
  case  2: break;                           // Vector  2:  ADC overflow
  case  4: break;                           // Vector  4:  ADC timing overflow
  case  6:                                  // Vector  6:  ADC12IFG0
    temp = ADC12MEM0;                       // Move results, IFG is cleared
    __bic_SR_register_on_exit(LPM4_bits);   // Exit active CPU
    break;
  case  8: break;                           // Vector  8:  ADC12IFG1
  case 10: break;                           // Vector 10:  ADC12IFG2
  case 12: break;                           // Vector 12:  ADC12IFG3
  case 14: break;                           // Vector 14:  ADC12IFG4
  case 16: break;                           // Vector 16:  ADC12IFG5
  case 18: break;                           // Vector 18:  ADC12IFG6
  case 20: break;                           // Vector 20:  ADC12IFG7
  case 22: break;                           // Vector 22:  ADC12IFG8
  case 24: break;                           // Vector 24:  ADC12IFG9
  case 26: break;                           // Vector 26:  ADC12IFG10
  case 28: break;                           // Vector 28:  ADC12IFG11
  case 30: break;                           // Vector 30:  ADC12IFG12
  case 32: break;                           // Vector 32:  ADC12IFG13
  case 34: break;                           // Vector 34:  ADC12IFG14
  default: break;
  }
}

 

  • James,

    you will need to combine one of the serial communication (UART/SPI/I2C) [USCI module] code examples with this ADC12 code example to create your Temp/Vcc TX RX code. As you could tell, we usually provide code examples for individual modules. But combining those modules to realize your own application can be as easy as putting their code files together and tweaking your main function. 

    Regards,

    Dung

  • James Moore said:
    but this isnt what i am looking for

    So what exactly ARE you looking for?

    The only way to really read the internal temperature sensor is to make a reading at 0° (C/F) and e.g. 80°(C/F). The fifference divided by the difference in degrees is the value per degree, while the value at 0° is the offset.

    Every device has its own offset and increment. On some MSPs, these values are taken by TI during burn-in and stored in INFO memory or TLV structure (along with other calibration values such as a correction factor for the reference voltage or the DCO settings for some fixed frequencies).

    On others there is no such info (it takes time and time is money = higher device production costs) and it's left to you to get them for each individual device.

  • Jens-Michael Goss,

    I am really looking for a little direction.   If I am not looking in the right area, I was hoping someone could help me.  There is alot of information on the TI website and it seems like I stumble across something new every time I visit.  BTW, Thanks for explaining how the internal temperature is calculated.  Any advice is appreciated.

    Thanks for your help.

    James

  • Dung,

    Thanks for the advice.  I have been going over the two code examples below:

    cc430x613x_uscib0_i2c_06.c   USCI_B0 I2C Master TX single bytes to cc430 Slave
    cc430x613x_uscib0_i2c_07.c   USCI_B0 I2C Slave RX single bytes from cc430 Master

    On a different note .....I am starting to draw my schematic using Eagle/Cadsoft.  I have found the "CC430x613x Code Examples" file but Eagle doesnt recognize them.  Is there a freeware that TI may offer to design my board that would recognize the .gdo files?

    Thank you,

    James

     

     

  • I am Jame's design partner. We now have code that is working to some degree. We were able to combine the simple peer to peer code with the ADC12 temperature sensor code below:

    #include "cc430x613x.h"

    volatile long temp;
    volatile long IntDegF;
    volatile long IntDegC;

    void main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
     
      /* Initialize the shared reference module */
      REFCTL0 |= REFMSTR + REFVSEL_0 + REFON;    // Enable internal 1.5V reference
     
      /* Initialize ADC12_A */
      ADC12CTL0 = ADC12SHT0_8 + ADC12ON;  // Set sample time
      ADC12CTL1 = ADC12SHP;                     // Enable sample timer
      ADC12MCTL0 = ADC12SREF_1 + ADC12INCH_10;  // ADC input ch A10 => temp sense
      ADC12IE = 0x001;                          // ADC_IFG upon conv result-ADCMEMO
     
      __delay_cycles(75);                       // 35us delay to allow Ref to settle
                                                // based on default DCO frequency.
                                                // See Datasheet for typical settle
                                                // time.
      ADC12CTL0 |= ADC12ENC;

      while(1)
      {
        ADC12CTL0 |= ADC12SC;                   // Sampling and conversion start

        __bis_SR_register(LPM4_bits + GIE);     // LPM4 with interrupts enabled
        __no_operation();

        // Temperature in Celsius
        // ((A10/4096*1500mV) - 894mV)*(1/3.66mV) = (A10/4096*410) - 244
        // = (A10 - 2438) * (410 / 4096)
        IntDegC = ((temp - 2438) * 410) / 4096;

        // Temperature in Fahrenheit
        // ((A10/4096*1500mV) - 829mV)*(1/2.033mV) = (A10/4096*738) - 408
        // = (A10 - 2264) * (738 / 4096)
        IntDegF = ((temp - 2264) * 738) / 4096;
       
        __no_operation();                       // SET BREAKPOINT HERE
      }
    }

    #pragma vector=ADC12_VECTOR
    __interrupt void ADC12ISR (void)
    {
      switch(__even_in_range(ADC12IV,34))
      {
      case  0: break;                           // Vector  0:  No interrupt
      case  2: break;                           // Vector  2:  ADC overflow
      case  4: break;                           // Vector  4:  ADC timing overflow
      case  6:                                  // Vector  6:  ADC12IFG0
        temp = ADC12MEM0;                       // Move results, IFG is cleared
        __bic_SR_register_on_exit(LPM4_bits);   // Exit active CPU
        break;
      case  8: break;                           // Vector  8:  ADC12IFG1
      case 10: break;                           // Vector 10:  ADC12IFG2
      case 12: break;                           // Vector 12:  ADC12IFG3
      case 14: break;                           // Vector 14:  ADC12IFG4
      case 16: break;                           // Vector 16:  ADC12IFG5
      case 18: break;                           // Vector 18:  ADC12IFG6
      case 20: break;                           // Vector 20:  ADC12IFG7
      case 22: break;                           // Vector 22:  ADC12IFG8
      case 24: break;                           // Vector 24:  ADC12IFG9
      case 26: break;                           // Vector 26:  ADC12IFG10
      case 28: break;                           // Vector 28:  ADC12IFG11
      case 30: break;                           // Vector 30:  ADC12IFG12
      case 32: break;                           // Vector 32:  ADC12IFG13
      case 34: break;                           // Vector 34:  ADC12IFG14
      default: break;
      }
    }

    When we run this code the temperature reports -10. How do we calibrate? Also, we have the eZ430 Chronos Development tool and would like to use C1111 usb access point to packet sniff for the purpose of logging the temps of the two development boards from the FET430F6137RF900. I have download the TI Packet sniffer, but code to load on the access point was not in the folder. We have about 10 days to have this done so any help will greatly be appreciated!

     

    Thanks,

    Kyle Thigpen

  • Kyle,

    Temperature Calibration

    asdf

    Please refer to the TLV structure section in the CC430 User's Guide and the device datasheet for specific info & formula on how to use the calibration. But here's a snippet of code that you can incorporate to take the cal. data into your temp calculation.

       int CAL_ADC_20T30, CAL_ADC_20T85;
       float m, c;
     
      CAL_ADC_20T30 = (*(int *)0x01A1E); //ADC temp calibration consts for 2.0V ref 
      CAL_ADC_20T85 = (*(int *)0x01A20);
     
      m = (85-30)/(float)(CAL_ADC_20T85 - CAL_ADC_20T30); //calculate the slope = m
      c = 85 - m*CAL_ADC_20T85;  // offset = c
      ...............

      degreeC = (ADC12MEMx * m + c);

     

    Also notice that some of the CC430 devices in silicon revision E are affected by erratum ADC27 pertaining to the incorrect temp. sensor cal values. If your devices are indeed affected, you will need to recalibrate manually, or swap out the silicon.

    CC1111 USB Access Point

    The CC1111 USB AP is not reprogrammable without external connections (soldering wires) to a CC-Debugger USB hardware, which does not come with the kit. In order to use the CC1111 Sniffer firmware, you will need to use the Debugger to reprogram the CC1111 USB AP stick, or preferably the CC1111EMK kit (also a USB stick) which already provides headers to connect to the CC-Debugger.

    Regards,

    Dung

  • Dung,

    Reprogramming the stick won't be a problem, I am looking for the sample code that goes on the stick.

    Thanks,

    Kyle

  • I have located the hex files and download the Smart RF Flash Programmer. I will load the AP tomorrow and hopefully get it working.

    Thank you,

    Kyle

**Attention** This is a public forum