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.

MSPM0G3507: ADC event trigger queued when in SW trigger mode

Part Number: MSPM0G3507

Hi,

a customer needs to set up the ADC to be triggered either by timer or by SW. They keep the timer always running. When they want to trigger by SW in between, they disable conversion, re-configure for SW trigger, and enable conversion again, which works great.
However, when switching back to HW trigger, the ADC starts conversion immediately, it seems that the timer has signaled an event to trigger the ADC in the meantime, this trigger is queued and serviced immediately when the ADC conversion is enabled again.

How can the queued trigger event be cleared before enabling the ADC conversion again?

BR,
Philipp

  • I would recommend to do it like this: When they want to trigger by SW, stop the timer and they disable conversion, re-configure for SW trigger. When switching back to HW trigger, clear the counter of the timer and re-start it.

  • Hi Gary,

    this is not an option as the timer serves for other purposes as well. What other options can we recommend?

    BR,
    Philipp

  • Sorry for the later response. If you can't stop the timer, I think you can try to clear the specific trigger event in ICLR register by API named DL_Timer_clearInterruptStatus(); that you used to trigger the ADC to  do conversion.

  • Hi Gary,

    using DL_Timer_clearInterruptStatus() clears the RIS bit for CPU event (interrupt), but leaves RIS bit of generic event route untouched. In this case, it's the zero-event of the timer. With this bit still set, the timer event still serves as ADC trigger.

    Any other ideas?

    BR,
    Philipp

  • Oh sorry provide the wrong API, it should be this one DL_Timer_clearEventsStatus()

  • Hi Gary,

    as discussed offline, please find attached the files that I used for my tests.

    adc12_triggered_by_timer_event.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    /*
    * Copyright (c) 2020, Texas Instruments Incorporated
    * All rights reserved.
    *
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    *
    * * Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    *
    * * Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in the
    * documentation and/or other materials provided with the distribution.
    *
    * * Neither the name of Texas Instruments Incorporated nor the names of
    * its contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    *
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    adc12_triggered_by_timer_event.syscfg

    BR,
    Philipp

  • It seems some wrong with the event trigger module, I got a workaround for this issue that when you modify the ADC's trigger source modify the timer's event publish channel ID, for example the normal timer event publish ID is 1, when you switch ADC trigger source to software you change the timer's event publish ID to 0 as below

      DL_ADC12_disableConversions(ADC12_0_INST);
    ADC12_0_INST->ULLMEM.CTL1 &= ~(ADC12_CTL1_TRIGSRC_MASK);
    DL_TimerG_setPublisherChanID(TIMER_0_INST, DL_TIMER_PUBLISHER_INDEX_0, 0);
    DL_ADC12_enableConversions(ADC12_0_INST);

    And when you want to switch ADC trigger source to hardware you need to change the timer's event publish ID to 1

    DL_ADC12_disableConversions(ADC12_0_INST);
    DL_TimerG_setPublisherChanID(TIMER_0_INST, DL_TIMER_PUBLISHER_INDEX_0, 1);
    ADC12_0_INST->ULLMEM.CTL1 |= ADC12_CTL1_TRIGSRC_MASK;
    DL_ADC12_clearInterruptStatus(ADC12_0_INST,0xFFFFFFFF);
    DL_ADC12_enableConversions(ADC12_0_INST);