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.

MSP430F2002 - precise ADC conversion timing from TimerA

Other Parts Discussed in Thread: MSP430F2002

Hello:

I am using the MSP430F2002 and I have a PWM output generated by Timer_A2 ; CCR0 and CCR1.  CCR1 also generates an interrupt that calls an ISR to run four selected ADC channel conversions.  The goal is to provide precise timing for the first channel converted. 

The problem is, I cannot get the conversions to occur except when the program is paused and then step through the code.  I can block out the code after one conversion, and that channel will convert at full speed.

Some specific questions:

  • I'm using "while" loops in the ISR to wait for conversions to be completed--Is this allowed?  The calculated conversion time should finish well before another interrupt occurs.
  • Do you have any source for example code for multi-channel manually selected ADC10 conversions?  None of the literature I've found shows this for the MSP430.  I am wondering if there are some delays that need to be added (I've tried a few).

Any feedback or input is welcomed and appreciated!

Thanks again!

Paul

  • It might be helpful to attach the code, or at least snips of code, to the thread.  If you include a large code sampling, please attach to the thread rather than copy-and-paste.  It is just a little easier to digest.

    Below are some responses to your posed questions.

     

    PaulSchoenke said:

    I'm using "while" loops in the ISR to wait for conversions to be completed--Is this allowed?  The calculated conversion time should finish well before another interrupt occurs.

    While allowed, I would not advise doing this.  I would suggest setting up the ADC10 to be triggered directly from the TimerA2 CCR1 to model your application description.  Figure 22-1 in the MSP430x2xx Family User's Guide on the MSP430F2002 Product Folder illustrates the options for the trigger mechanism for the Start-Of-Conversion signal.

    You then can use the TimerA2 interrupt to service the timer but not spend cycles starting the conversion process of the ADC10 and waiting for completion.

    Then setup the ADC10 to generate an interrupt at the completion of the conversions as the examples cited below provide a framework.

     

    PaulSchoenke said:

    Do you have any source for example code for multi-channel manually selected ADC10 conversions?  None of the literature I've found shows this for the MSP430.  I am wondering if there are some delays that need to be added (I've tried a few).

    Yes, there are a couple of simple code examples that setup the ADC10 for multi-channel conversions.  These are included in the MSP430F20x1, MSP430F20x2, MSP430F20x3 Code Examples (Rev. I) found on the MSP430F2002 Product Folder in the Software & Development Tools section.

    I would suggest you look at msp430x20x2_adc10_10.c and msp430x20x2_adc10_14.c as examples for multi-channel conversions with an interrupt from the ADC10 for indication of the completion of the conversion.

  • Thanks very much Brandon!

    • Thanks for the recommendation on using the timer triggered conversion.  We could probably come up with a way to guarantee the ADC10 has its mux input selected to do the conversion we want, before the timer interrupt fires--then re-call the ISR in software after each selection of the second, third, fourth..., input channels in a second ISR.     
    • The example code you referenced does not show how to do multi-channel manually selected ADC10 conversion.  It only shows how to do the automated sequence of channels approach.  Any further suggestions here?

    Thanks again!

    Paul

  • To elaborate further, I'm sampling 5 channels in my system and the one channel that needs to be sampled with precise timing changes depending upon conditions in the system.  I'm not that concerned with the timing on the other channels.   That's the reason that I'm looking for specifics on the single manually selected channel.  I want to execute this conversion as quick as possible when an interrupt with the specific conditions fires.

  • PaulSchoenke said:
    w how to do multi-channel manually selected ADC10 conversion

    Teh ADC10 does not allow individual channel sequences. you can only set it up for sampling one channel or for sampling a sequence from channel x down to channel 0. If you don't need all inputs of sucha count-down sequence, you'll need to sample-and.ignore the values you don't need.

    The ADC12 in other MSPs lets you configure a sequence of up to 16 steps with a freely selectable channel and reference each, even with one channel sampled multiple times within a sequence.

  • Hello,

    Thanks very much for the response!

    Essentially, I want to manually select a channel and convert it, then manually select another channel, and convert that..., etc.

    Is there a good process for achieving this?

    Thanks again!

    Paul

  • PaulSchoenke said:
    Is there a good process for achieving this?

    You already wrote it:
    PaulSchoenke said:
    manually select a channel and convert it, then manually select another channel, and convert that

    Depending on your timing requirements, you may set up an ISR that is triggered after each conversion. In this ISR you read the result, set up the ADC for the next channel and start the next conversion.

**Attention** This is a public forum