• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Microcontrollers » MSP430™ Microcontrollers » MSP430 Ultra-Low Power 16-bit Microcontroller Forum » ADC12 configuration for msp430f5xxx series
Share
MSP430™ Microcontrollers
  • Forum
  • Announcements
  • E2E Wiki
Options
  • Subscribe via RSS
MSP430 Resources
  • MSP430 Product Folder
  • MSP-EXP430G2 - MSP430 LaunchPad Value Line Development kit
  • MSP430 Getting Started Guide
  • MSP430 Microcontroller Projects
  • More Resources >
  • ADC12 configuration for msp430f5xxx series

    ADC12 configuration for msp430f5xxx series

    This question is not answered
    Ars
    Posted by Ars
    on May 21 2012 04:18 AM
    Prodigy190 points

    Hi ,

       I have an application involving ADC12 of  msp430f5324 device where signal to be measured of 50 Hz to 200 Hz      

        Frequency and I have 8 such signals.

     

        Q1 . I want to be sure whether the way I am configuring & using the ADC is correct ? I have not used internal 

        ADC12OSC assuming that it requires  a calibration routine and can vary from 4.2 to 5.4 MHz.

         In a  'sequence of channels" mode shall i first reset ADC12SC bit and then read the ADC12MEMx ?

        My objective is :

    a)      Start the sample & conversion  from timer interrupt routine.

    b)      By the time next timer interrupt( 156.25 usec later) comes, adc should  have sampled & converted  and store the result  of all 8 channel in adc buffer.

        void adcInit(){

            REFCTL0 &= ~REFMSTR;              

            __delay_cycles(5);   

     

            ADC12CTL0 &= ~ADC12ENC; 

            ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_4+ADC12SHT1_4+ADC12REF2_5V+ADC12REFON;                                                                                             

            ADC12CTL1 = ADC12SHP+ADC12CONSEQ_1+ADC12SSEL_3+ADC12DIV_6; // seq of ch +  adcclk : SMCLK/7                                            

            ADC12CTL2 = ADC12RES_2;        // Resolution : 12 Bit 

            ADC12MCTL0 = ADC12SREF_1+ADC12INCH_0;          // ref+= vref, channel = A0

            ADC12MCTL1 = ADC12SREF_1+ADC12INCH_1;          // ref+= vref, channel = A1

            ADC12MCTL2 = ADC12SREF_1+ADC12INCH_2;          // ref+= vref, channel = A2

            ADC12MCTL3 = ADC12SREF_1+ADC12INCH_3;          // ref+= vref, channel = A3

            ADC12MCTL4 = ADC12SREF_1+ADC12INCH_4;          // ref+= vref, channel = A4

            ADC12MCTL5 = ADC12SREF_1+ADC12INCH_5;          // ref+= vref, channel = A5

            ADC12MCTL6 = ADC12SREF_1+ADC12INCH_6;          // ref+= vref, channel = A6

            ADC12MCTL7 = ADC12SREF_1+ADC12INCH_7;          // ref+= vref, channel = A7

            ADC12MCTL8 = ADC12SREF_1+ADC12INCH_8+ADC12EOS; // ref += vref, channel = A8,end of sequence      

             ADC12CTL0 |= ADC12ENC;                    // Enable conversions

            ADC12CTL0 |= ADC12SC;                     // Start convn - software trigger

           __delay_cycles(75);                              // stabilize  internal vref

     

     

       }

     

       void Timer interrupt routine(){ // will call it @ 156.25 usec  or  6400 Hz

     

         // Read all samples  from ADC12MEMx

        

         // accumulate  n  sample in a buffer ;

         ADC12CTL0 &= ~( ADC12ENC + ADC12SC ) ;

         ADC12CTL0 |= ( ADC12ENC + ADC12SC ) ;

      } 

        void main(){

            --------

            adcInit();

           while(1){

             // process the accumulated samples.

           } 

      } 

     Q2 . pls refer the following details from data sheet .

        Let’s  say 25 MHz crystal oscillator used and MCLK = 25 MHz and  ADC12CLK source is MCLK.

        Ref  used is internal vref . so SREF1 = 1  & REFOUT = 0 ,ADC12SR = 0

        And does it mean to say in the above scenario  fADC12CLK  would be 0.45  to 2.7 MHz

        Correct me if I  have mistaken!

    Thanks n regards

    Ars

     

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    All Replies
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on May 22 2012 10:20 AM
      Guru141810 points

      Ars
      I have not used internal ADC12OSC assuming that it requires  a calibration routine and can vary from 4.2 to 5.4 MHz.

      Ther eis no 'calibration'. Of course you can determine the exact frequency and take it into account, but for your applicaiton this is not necessary. You provide the start timing for a swequence by a timer, So it doesn't matter whether the sequence takes a few µs more or less. The important thing is the distance between two sequence runs and this is determined by the timer.

      Ars
       In a  'sequence of channels" mode shall i first reset ADC12SC bit and then read the ADC12MEMx ?

      No. When an individual ADC121MEMx result is available, its corresponding IFG bit is set and you can read the value immediately.
      ADC12SC itself is automatically cleared when the sequence is finished. At least when SHP bit is set and you only trigger teh start of the sequence. (if SHP is clear, you directly control the sampling buffer gate with ADC12SC, so you must set and clear it for every single conversion)

      Ars
      Start the sample & conversion  from timer interrupt routine.

      Not the best solution, except if you want to determine inside the ISR whether to start a sequence at all. Using a CCR units output bit (usually TACCR0, TBCCR0 or TBCCR1) can do it at the exact moment of the timer event without need for any software. See ADC12SHSx

      Ars
      By the time next timer interrupt( 156.25 usec later) comes, adc should  have sampled & converted  and store the result  of all 8 channel in adc buffer.

      Why not instead having an ISR triggered by the ADC12 interrupt that is triggered when a specific ADC12IFGx bit is set (usually, the one for the last ADC12MEM in the sequence is used, but for tight timing and to overcome interrupt latency, the forelast step in the sequence can be used to trigger the interrupt, or two of them for first and second half of a sequence)

      Ars
          Let’s  say 25 MHz crystal oscillator used and MCLK = 25 MHz and  ADC12CLK source is MCLK.

      I do not recommend it. Using MCLK as clock for the ADC12 prevents the MCU from going into LPM.

      Ars
      And does it mean to say in the above scenario  fADC12CLK  would be 0.45  to 2.7 MHz

      No. You use MCLK=25MHz and ADC12DIV_6 (which divides the clock /7 and equals ADC12DIV__7 - note the double underscore) so fADC12CLK will be exactly 25/7=3.57MHz.

      In this case you'llneed to set REFOUT=1 and provide the required external capacitors. Same for using ADC12OSC. I'm a bit surprised that using ADC12OSC will operate the ADC ina way that it will leave the specified performance range when usign the internal reference. Thsi seems to be a limitation of thsi specific MSP. The 5438A doesn't have this limitation in the datasheet. The 5438 errata sheet, however, lists the 2.7MHz limitation with REFOUT=0.

      Well, you can still use REFOUT=0 and ADC12DIV_1 while staying with ADC12OSC. Just keep in mind that you have eight signals, each conversion takes 13+n clock ticks (n depends on ADC12SHTx setting) and the total needs to fit into your timing interval.

      Ars
         void Timer interrupt routine(){ // will call it @ 156.25 usec  or  6400 Hz

      didn't you say 200Hz? The sequence only needs to be started once every 1/200s for all channels being sampled with 200Hz. Where did you get the 6400Hz from?

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Ars
      Posted by Ars
      on May 26 2012 05:11 AM
      Prodigy190 points

      Hi   Jens !!

       Thanks .

      Jens-Michael Gross
      didn't you say 200Hz? The sequence only needs to be started once every 1/200s for all channels being sampled with 200Hz. Where did you get the 6400Hz from?

      Yes the frequency of the signal to be measured is between 50 Hz to 200 Hz . And My code  reads the ADC12 buffer  at a rate of 6400Hz ( 156.25  uSec). So the distance between two reading of 8 channel is 156.25 usec at a sys clock of 25 MHz.

      Actually I have to run a timer interrupt ( 156.25 usec) for other tasks. So I thought to use it for ADC too. Hence  explicitly started the sample & conversion of adc signal ( by setting ADC12SC bit)  from this routine.

      ADC12CTL0 = ADC12ON+ADC12MSC+ADC12SHT0_4+ADC12SHT1_4+ADC12REF2_5V+ADC12REFON;

       using ADC in a sequence of channel mode

      Hence each adc channel will take 64 + 13 ADC12Clk cycles. So 8 channel will take 8 x  ( 64 + 13 )adc12clk time which is well within my timer interrupt time.

      As per my understanding  ADC will finish one sequence of  sample & conversion and sit idle after 8 x  ( 64 + 13 )adc12clk time  and will wait for a rising edge on ADC12SC bit for next sequence and  that I am doing from the timer interrupt routine.

      My doubt is that If I do so, still adc12 sampling period will be as per ADC12SHT0_4, ADC12SHT1_4 bits?

      What is ADC12MSC bit does? Does it samples multiple time ? then how many samples?

      In general how much sample time will be required for <1LSB error?

      regards,

      Ars

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    • Jens-Michael Gross
      Posted by Jens-Michael Gross
      on May 27 2012 08:51 AM
      Guru141810 points

      Ars
      If I do so, still adc12 sampling period will be as per ADC12SHT0_4, ADC12SHT1_4 bits

      If you set the SHP bit, then yes, ADC12SHTyx controls the time the sampling gate is open to charge the sampling capacitor. For each and every sampling procedure.

      Ars
      What is ADC12MSC bit does? Does it samples multiple time ? then how many samples?

      If this bit is set, the ADC12 doesn't require an individual trigger for each conversion in a sequence. Next conversion of a sequence starts as soon as the previous one is done. If this bit is clear, you'll have to trigger each single conversion manually, even if you have a sequence.

      Ars
      In general how much sample time will be required for <1LSB error?

      It depends on your signal impedance. If you have a low-impedance signal source, only minimum sampling time is required. The higher the signal impedance, the higher smapling time is necessary to charge the sampling capacitor. Also, teh input multiplexer acts as a series resistance ( ~1k) to the sampling capacitor, which has some influence too, limiting bandwidth even on low-impedance signal sources.
      It is your job to figure out your system configuraiton and calculate the required minimum sampling time.

      _____________________________________
      Before posting bug reports or ask for help, do at least quick scan over this article. It applies to any kind of problem reporting. On any forum. And/or look here.
      If you cannot discuss your problem in the public, feel free to start a private conversation: click on my name and then 'start conversation'. But please do so only if you really cannot do it in a public thread, as I usually read all threads. And I prefer to answer where others can profit from it (or contribute to it) too.

      Report Abuse
      • Reply
      You have posted to a forum that requires a moderator to approve posts before they are publicly available.
    TI E2E™ Community
    • Support Forums
    • Blogs
    • Videos
    • Groups
    • Site Support & Feedback
    • Settings
    TI E2E™ Community Groups
    • TI University Program
    • Make the Switch
    • Microcontroller Projects
    • Motor Drive & Control
    Other Communities
    • Deyisupport
    • Designsomething.org
    • beagleboard.org
    • TI on Element 14
    • TI on TechXchangeSM
    Other Technical & Support Resources
    • WEBENCH® Design Center
    • Product Information Centers
    • Technical Documents
    • TI Design Network
    • TI Technical Articles
    • TI Training

    All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

    Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

    Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
    TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

    TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
    embedded processors, along with software, tools and the industry’s largest sales/support staff.

    © Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
    Trademarks | Privacy Policy | Terms of Use