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.

CCS/MSP-EXP430FR5994: Trouble making Timer A1 CCR1 triger ADC12 convertion using DRIVERLIB, Help

Part Number: MSP-EXP430FR5994

Tool/software: Code Composer Studio

Hi, i need some help with my code, i've configured the ADC and the TA1 modules so that the ADC conversion is triggered by the TA1, but it seems to be wrong, the TA1 interrupt works just fine, but the ADC is not been triggered.

for the ADC:

//Configuro pin para ADC
    GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P1,GPIO_PIN2,GPIO_TERNARY_MODULE_FUNCTION);
//Parametros de configuracion
    ADC12_B_initParam initParam = {0};
    initParam.sampleHoldSignalSourceSelect = ADC12_B_SAMPLEHOLDSOURCE_4; //Disparo por TIMER A1 CCR1
    initParam.clockSourceSelect = ADC12_B_CLOCKSOURCE_ADC12OSC;
    initParam.clockSourceDivider = ADC12_B_CLOCKDIVIDER_1;
    initParam.clockSourcePredivider = ADC12_B_CLOCKPREDIVIDER__1;
    initParam.internalChannelMap = ADC12_B_NOINTCH;
    ADC12_B_init(ADC12_B_BASE, &initParam);
//Activo ADC_12 para inicializacion
    ADC12_B_enable(ADC12_B_BASE);
    ADC12_B_setupSamplingTimer(ADC12_B_BASE,ADC12_B_CYCLEHOLD_16_CYCLES,ADC12_B_CYCLEHOLD_4_CYCLES,ADC12_B_MULTIPLESAMPLESDISABLE);
//Configuracion de ADCMEM
    ADC12_B_configureMemoryParam configureMemoryParam = {0};
    configureMemoryParam.memoryBufferControlIndex = ADC12_B_MEMORY_0;
    configureMemoryParam.inputSourceSelect = ADC12_B_INPUT_A2;
    configureMemoryParam.refVoltageSourceSelect = ADC12_B_VREFPOS_AVCC_VREFNEG_VSS;
    configureMemoryParam.endOfSequence = ADC12_B_NOTENDOFSEQUENCE;
    configureMemoryParam.windowComparatorSelect = ADC12_B_WINDOW_COMPARATOR_DISABLE;
    configureMemoryParam.differentialModeSelect = ADC12_B_DIFFERENTIAL_MODE_DISABLE;
    ADC12_B_configureMemory(ADC12_B_BASE, &configureMemoryParam);
    ADC12_B_clearInterrupt(ADC12_B_BASE,0,ADC12_B_IFG0);
//Interrupcion para ADC
    //ADC12_B_enableInterrupt(ADC12_B_BASE,ADC12_B_IE0,0,0);
//Configuro DMA para ADC
    DMA_initParam param = {0};
    param.channelSelect = DMA_CHANNEL_0;
    param.transferModeSelect = DMA_TRANSFER_SINGLE;
    param.transferSize = 10;
    param.triggerSourceSelect = DMA_TRIGGERSOURCE_26;   //ADC
    param.transferUnitSelect = DMA_SIZE_SRCWORD_DSTWORD;
    param.triggerTypeSelect = DMA_TRIGGER_RISINGEDGE;
    DMA_init(&param);
    MemADC=ADC12_B_getMemoryAddressForDMA (ADC12_B_BASE,ADC12_B_MEMORY_0);
    DMA_setSrcAddress(DMA_CHANNEL_0,MemADC,DMA_DIRECTION_UNCHANGED);
    DMA_setDstAddress(DMA_CHANNEL_0,&ADCval,DMA_DIRECTION_INCREMENT);
    DMA_enableTransfers(DMA_CHANNEL_0);

for the Timer A1 and CCR1

    //Configuro TIMER A0 PARA QUE DISPARE MUESTREO
    Timer_A_initContinuousModeParam initContParam = {0};
    initContParam.clockSource = TIMER_A_CLOCKSOURCE_ACLK;   //CLK=32.745Khz
    initContParam.clockSourceDivider = TIMER_A_CLOCKSOURCE_DIVIDER_1;
    initContParam.timerInterruptEnable_TAIE = TIMER_A_TAIE_INTERRUPT_DISABLE;
    initContParam.timerClear = TIMER_A_DO_CLEAR;
    initContParam.startTimer = false;
    Timer_A_initContinuousMode(TIMER_A1_BASE, &initContParam);
    //Initiaze compare mode
    Timer_A_clearCaptureCompareInterrupt(TIMER_A1_BASE,TIMER_A_CAPTURECOMPARE_REGISTER_1);

    Timer_A_initCompareModeParam initCompParam = {0};
    initCompParam.compareRegister = TIMER_A_CAPTURECOMPARE_REGISTER_1;
    initCompParam.compareInterruptEnable = TIMER_A_CAPTURECOMPARE_INTERRUPT_ENABLE;
    initCompParam.compareOutputMode = TIMER_A_OUTPUTMODE_OUTBITVALUE;
    initCompParam.compareValue = 64;
    Timer_A_initCompareMode(TIMER_A1_BASE, &initCompParam);
    Timer_A_startCounter( TIMER_A1_BASE,TIMER_A_CONTINUOUS_MODE);

  • Hi,

    It looks like your issue likely has to do with lines 15 and 16 or your timer initialization code. First, you are using the timer ISR, so you may be clearing the interrupt flag before it can be seen by the ADC, which would explain why the ADC is not being triggered. Second, in line 16 you are setting the compare output mode to TIMER_A_OUTPUTMODE_OUTBITVALUE. This should be set to something else, such as toggling the output value, to trigger the ADC.

    Regards,
    Nathan
  • Hi,

    Was your issue resolved? If so, please mark it as answered. If no response, this thread will be closed soon.

    Regards,
    Nathan
  • Hi, i'm sorry for the delay, no the issue wasn't solved, i've tried charging CCR0 with a value of 64 and CCR1 with a value of 60, Using the set-reset mode and disabling the TA interrupt, but it doesn't work jet.

  • Hi,

    You wouldn't necessarily want to disable the TA interrupt. It depends on how you are using the ISRs. You just want to make sure that you are not clearing the interrupt flag when you are expecting another module to be looking for it to be set. If you include your ISRs here I could see if there are any issues with your interrupt handling logic.

    Regards,
    Nathan
  • Hi, im sorry for the delay, again, well i'm not using the TA ISR, i was just using it to make sure that the TA was working, i use DMA with the ADC so, when 100 samples are taken an interrupt should take place, explaining just a bit more, the TA just triggers the ADC, i'm not using it for anything else.

  • Hi,

    I do not see anywhere where you are using the timer as a trigger for the ADC. Your DMA configuration code is not doing this. If you already have gotten the timer to generate an interrupt, then why don't you just use that ISR to enable the ADC (and have it disabled before that)?

    Regards,
    Nathan
  • Hi thanks, for the quick response. Yes i defined the CCR1 overflow as a trigger for the ADC, you can see this in LINE 5 of the code  for the ADC, i've tried using the ISR of the TA1 in order to trigger the ADC, and it works, but i don't want to use an ISR to trigger the ADC since i can use the CCR1 overflow

  • Try inserting this after your ADC setup:
    > ADC12CTL0 |= ADC12ENC; // Enable (note: locks most of the ADC12CTLx fields)

    Looking through the source I have (2.70.01.01 I think) for adc12_b.c,I haven't been able to figure out how to do this via driverlib. But this should get you going.

    Unsolicited: I suspect you'll do better with CONSEQ=2 rather than CONSEQ=0, since you won't have to wiggle ADC12ENC each time around (see also SLAU367N Fig 34-10 vs Fig 34-8). I'm not sure how you're supposed to set this (with driverlib) either, but you can insert this line just before the line I suggested above:

    > ADC12CTL1 |= ADC12CONSEQ_2; // Repeat single channel once per trigger (MSC=0)
  • Well I'm actually doing that, disabling ADC before the configuration takes place, and enabling it after it is done, with the command ADC12_B_enable(ADC12_B_BASE);

    Well I'm doing this (the ADC configuration, not the use of DMA or TA1)  just as it is in the example for driver lib in resource explorer.

    Everything is working just fine, but the problem is the triggering from the TA1

  • > Everything is working just fine, but the problem is the triggering from the TA1

    Did you make the change I suggested? When I made that change, TA1 triggered fine (once).
  • It occurred to me that maybe the intended usage is to call ADC12_B_startConversion(), which sets both CONSEQ and ENC (per above).

    It also sets ADC12SC, but maybe (? I've never tried it) SC is ignored if SHS != 0.

    I still suspect you want CONSEQ=2.
  • Hi,

    Has this issue been resolved? If so, please mark it as answered.

    Regards,
    Nathan

**Attention** This is a public forum