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.

MSPM0G1507: use of Timer EVENT1 and EVENT2

Part Number: MSPM0G1507

Tool/software:

Hi,
I want to use Timer0 Event1 interrupts zero, load to trigger ADC0 ch1 for mem 1 and Timer0 Event2 interrupt CMP to trigger ADC0 ch2 for mem2. Is this possilbe?
Then can ADC0 trigger 2 different EOC interrupts? Or can the MEMx loaded result interrupt be read in some register in the EOC interupt routine?

Regards, Holger

  • Hi Holger,

    The only limitation that I am seeing is that one ADC can only subscribe to one event, so this wouldn't exactly be possible.

    You could have a single timer generating two different events, and then have ADC0 subscribe to one event, and ADC1 subscribe to the other.

    Alternatively, if you know you are always going to have ADC channel 1 and 2 firing on an alternating basis, you could subscribe the one ADC module to the timer event, then just have the timer publish both events. Then put the ADC into sequence mode with channels 1 and 2.

    For your secondary question, ADCx can trigger a memory result loaded interrupt, meaning that the interrupt fires when a conversion result is loaded into the result register. So you could enable this to trigger an interrupt when ch1 result is loaded, and ch2 result is loaded. There is not a singular "end of conversion" interrupt, we use the memory result loaded interrupts instead.

  • Hi Dylan,
    ok, understood.

    > So you could enable this to trigger an interrupt when ch1 result is loaded, and ch2 result is loaded. 
    This will be the same interrupt handler? How to distinguish between which ch has triggered the interrupt?

    Regards, Holger

  • The same ISR is executed for a ch1 result loaded and ch2 result loaded. When you enter the ISR, you can use the DL_ADC12_getPendingInterrupt() function to determine which memory result has triggered the ISR. For an example of this, please see this example in TI Resource Explorer. You can see inside of the ISR you can just use a case statement with the DL_ADC12_IIDX_MEMx_RESULT_LOADED defines to execute certain bits of code for particular memory result loaded interrupts.

  • Hi Dylan,
    what about using the sequence ADC mode and generate the 4 events with Event 1: Zero, CMP UP, load, CMP down. With the 4 Event1s you can trigger the 4 ADC conversions. You could start the ADC each time with the event 2 = Zero per SW/CPU. Would that work?

    Regards, Holger

  • I think that could work for the most part, but the exception is that using the CMP UP and CMP down events won't work, because the timer can only be in 1 up or down mode. What you could do is: CMP UP on channel 0, load, zero, CMP UP on channel 1.

    Re-reading your post though, you would not need the event 2 that "starts the ADC". Im not sure I fully understand what you mean here but - you'll power on and initialize the ADC in your source code, then the events that the ADC subscribes to will simply trigger conversions. So I do not understand / think you need the event 2 portion here. If I am misunderstanding please add some clarification on what you intend for event 2 to do here.

  • Hi Dylan,
    I thought the timer can count in up/down mode (see chapter 27.2.2.3 Up/Down Counting Mode):

    > Re-reading your post though, you would not need the event 2 that "starts the ADC".
    As we have only one event for the ADC for the for events (zero, up, load, down) I thought it is not clear which signal will be measured when. So I wanted to use Event2 for synchronization with the zero event.

    Regards, Holger

  • Apologies Holger, you're right we do have the up/down mode. You could use this and get the up and down signals both with the one configuration.

    There is not an event to restart the ADC sequence, you would need to either ensure that the sequence is reliably firing on the intended event by testing it, or you could use software to reset the ADC peripheral between sequences.

  • Hi Dylan,

    > you could use software to reset the ADC peripheral between sequences.
    how to reset the ADC?

    Regards, Holger

  • Please take a look at the 

    DL_ADC12_reset(ADC12_0_INST); 
    API. Note that after doing this you'd need to reinitialize the ADC. 
  • Hi,

    so with DL_ADC12_reset(ADC12_0_INST);
    the complete ADC configuration is reseted?

    Regards, Holger

  • That is correct, the ADC settings should not be retained after using the reset API.