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.

Setting up Grace for Single-channel Repeated conversion

Other Parts Discussed in Thread: MSP430G2553

Hi everyone,

I started playing with Grace today and so far I've understood how to use it for Timers, UART, GPIO… but I'm having troubles setting up the ADC10 (I am using a MSP430G2553). I would like to periodically read a value from one pin (any) with the ADC10 and send it to another device over UART. I did some independent tests and I got the UART working fine.

For doing this, it seemed to me that the best setting was the "Single-channel Repeated conversion" described in the Grace how-to. The steps are the following:

  1. Enable the ADC10 and select the Power User View
  2. Select single channel and repeated conversion mode on ADC channel 0 and enable the external GPIO pin as needed (not clear to me...)
  3. Select a timer in the ADC Trigger source and configure the respective Grace timer module to generate a PWM signal
  4. Enable Automatic Data Transfer and specify the memory start address and a block size
  5. Enable the Analog to Digital Converter Interrupt. You can insert your custom ISR code inside ADC10_ISR_HOOK in src/grace/InterruptVectors_init.c
I did all of these but the ADC10_ISR_HOOK interrupt never occurs (I used breakpoints and LED1 toogling to check) even though I checked the box at the bottom.
I guess my driving PWM Timer is set up correctly because I've put it on the LED2 and it is blinking as expected. I've put the Timer0_A3 as the ADC trigger source. However, I am not sure that I understand well the settings "Enable ADC Channel config" and "Enable External GPIO Pin" on the left. What are they exactly and what happens if I select none of them? How can I set which pin to read from?
What could be the explanation for the interrupt not to occur? Do I need to add additional code in the main file to start the conversion process?
Thank you for your explanations
  • Hi guill8,

    On the left side of Power User View you`ll find, that you are able to enable external GPIO Pin, that`s where you set which pin to read from.  On the same side you can pick single channel or sequence of channels. I suppose, single channel is what you need.

    As I understand, you have already selected repeated conversion as conversion type. As ADC clockSource you should choose ADC10OSC or ACLK (possible for LPM0-LPM3), SMCLK (LPM0), MCLK (only active power mode).There is the function  __bis_SR_register(LPM3_bits + GIE);  in automatically generated main file, where you can adjust preferrable power mode.

    Another one important thing - diring timer configuration in Power user mode CCR0 you may select PWM output mode 4 as output mode.

    Let me know about your progress.

     

    Thank you,

    Yevhen

  • Thank you for your help. Indeed, I didn't know that I needed to use the mode 4 for the PWM, it was not said in the Grace step-by-step guide but, my bad, I probably should have gone through the documentation again. Anyhow, this also made me realize that I needed to select as a trigger "Timer_A3 Channel 1" and not "Timer_A3 Channel 0". I am not completely sure to understand what is going on with those two, and mainly why we the two of them.

    Another thing was the "Automatic Data Transfer Controller". When enabled, it stops working (no interrupt). If I've understood well, the idea is to sample very quickly (well, at the trigger's clock rate) and store that in memory for later handling and treatment - am I right ? What would I need to change to make this mode work, beside reading the data from the right place?

  • Hi, guill8,

    I don`t quite understand, why can`t you select Timer_A3 Channel 0 as ADC trigger source. It does work by me.

    By the automatic data transfer configuration, I suppose, you have manually set starting memory address like 0xXXX, and it could conflict with some existing memory sectors. For the beginner is safer to insert in the starting memory address field  the name of previously created array.

    For example if you`ll create the array like this:  int Th_array[20];, you may insert in the starting memory address field - Th_array, and in memory block size - 20.

     

    Best Ragards,

    Yevhen

     

  • Well, actually it works, you are right. I guess I got confused with another setting.

    Thanks again your your help, and also for the indications on automatic data transfer. I will have to check whether this can be useful in my application or not.

**Attention** This is a public forum