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.

MSP432P401V: IAR/ADC with Timer_A trigger

Part Number: MSP432P401V

I created code to sample multiple channels continuously. I triggered it with MAP_ADC14_toggleConversionTrigger(). This code was based on an example in the C:\ti\simplelink_msp432p4_sdk_3_20_00_06\examples\nortos\MSP_EXP432P401R\driverlib. It works.

Now, I want to trigger the ADC from Timer_A0. Once again, I used an example project and read the RM. I changed only two lines in my working ADC code as follows:

      bstatus = MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_ADCSC, false);

to

      bstatus = MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false);

and

MAP_ADC14_toggleConversionTrigger();

to

TMR_StartTimer( ADC_TIMER );

The timer is configured per an example project as follows:

const Timer_A_UpModeConfig upModeConfig =
{
        TIMER_A_CLOCKSOURCE_SMCLK,
        TIMER_A_CLOCKSOURCE_DIVIDER_64,  // 46875Hz
        46875,
        TIMER_A_TAIE_INTERRUPT_DISABLE,
        TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE,
        TIMER_A_DO_CLEAR
};

/* Timer_A Compare Configuration Parameter */
const Timer_A_CompareModeConfig compareConfig =
{
        TIMER_A_CAPTURECOMPARE_REGISTER_1,
        TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE,
        TIMER_A_OUTPUTMODE_SET_RESET,
        46875
};


extern LUNAR_ERROR_T TMR_Init( void )
{
    (void)MAP_Timer_A_configureUpMode(TIMER_A0_BASE, &upModeConfig);
    (void)MAP_Timer_A_initCompare         (TIMER_A0_BASE, &compareConfig);

    return ERR_NONE;
}

The timer does not trigger the ADC. I am expecting it to trigger every 1s. I never enter "void ADC14_IRQHandler(void)". I tried enabling a timer interrupt and adding the ISR, but I never got there either. Note that master interrupts are enabled early in Main().

What am I  missing?

  • As I read this, you're setting CCR0=CCR1 (=46875), which I'm pretty sure generates no pulse.

    Try setting CCR1 to something lower than CCR0, maybe (46875/2) or maybe just (1).

  • I tried that already and for the same reason. The nortos, driverlib example "adc14_single_conversion_repeat_timera_source.c" shows it this way. See below. The examples notes say "Timer_A is setup in Up mode and a Compare value of 16384 is set as the compare trigger and reset trigger."; Although, there are quite a few mistakes in that example. Not to mention Figure 22-8 in the RM shows ADC14ENC being a positive pulse, but the text above the figure says its a negative pulse. Wouldn't this detail affect the call to MAP_ADC14_setSampleHoldTrigger(ADC_TRIGGER_SOURCE1, false or true);??? Any other ideas?

    /* Timer_A Continuous Mode Configuration Parameter */

    const Timer_A_UpModeConfig upModeConfig =

    {

    TIMER_A_CLOCKSOURCE_ACLK, // ACLK Clock Source

    TIMER_A_CLOCKSOURCE_DIVIDER_1, // ACLK/1 = 32Khz

    16384,

    TIMER_A_TAIE_INTERRUPT_DISABLE, // Disable Timer ISR

    TIMER_A_CCIE_CCR0_INTERRUPT_DISABLE, // Disable CCR0

    TIMER_A_DO_CLEAR // Clear Counter

    };

     

    /* Timer_A Compare Configuration Parameter */

    const Timer_A_CompareModeConfig compareConfig =

    {

    TIMER_A_CAPTURECOMPARE_REGISTER_1, // Use CCR1

    TIMER_A_CAPTURECOMPARE_INTERRUPT_DISABLE, // Disable CCR interrupt

    TIMER_A_OUTPUTMODE_SET_RESET, // Toggle output but

    16384 // 16000 Period

    };

  • Hmm, I guess I remembered wrong.

    Are you fairly certain your timer is running? If the debugger shows TIMER_A0->R non-zero that's a good sign.

    What does "TMR_StartTimer( ADC_TIMER );" do exactly?

  • I've made some progress. I had a conflict with Timer_A0. So I changed from TA0_C1 to Timer_A1 and TA1_C1. The ADC now triggers one time after the approx. 1s timer timeout period, even when both timer values shown above are equal. The timer is configured in UpMode, so it should reset to 0 and start counting up again. The example does not show any code to reset any Timer flags. Only the ADC-related interrupt flags are reset in the ISR. So, more reading and trial and error from here. I'm not convinced the example project is correct, but I wasn't able to get the example project running in a short period of time due to differences in hardware.

  • What is CONSEQ  set to? With CONSEQ=1 (SHS != 0) you need to toggle ENC between batches [Ref TRM (SLAU356I) Fig 22-8]. If you don't you'll see a symptom similar to what you describe.

    As I recall that Example used CONSEQ=2.

  • I read that a dozen times, but assumed the example took care of it within one of the driverlib API calls. Upon a closer look though, there is no such code in the example's ISR. A comment within the example says:

    "Once the Timer_A is started, after 0.5s it will trigger
     * the ADC14 to start conversions. Essentially this example will use
     * the Timer_A module to trigger an ADC conversion every 0.5 seconds."

    I don't see where the example does this. And I do not see an API to do this. Is this the appropriate method? It worked.

    MAP_ADC14_disableConversion();

    MAP_ADC14_enableConversion();

  • Yes, those look like the ones. The Example doesn't need to do this since it uses CONSEQ=2 (with MSC=0).

**Attention** This is a public forum