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.

MSP430FR6877: ADC interrupt is no working

Part Number: MSP430FR6877
Other Parts Discussed in Thread: MSP430WARE

Hi,

I am using ADC input on A8 and it is working fine (I am configuring mem0 for it).

But I have another ADC input on A12, when I tried the same configuration as the working one (using mem1), the interrupt didn't come.

Could anyone help?

Code is as following:

1- P9.4/A12 init

GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P9, GPIO_PIN4, GPIO_TERNARY_MODULE_FUNCTION);

2- ADC init

   /*
    * Base address of ADC12B Module
    * Use internal ADC12B bit as sample/hold signal to start conversion
    * USE MODOSC 5MHZ Digital Oscillator as clock source
    * Use default clock divider/pre-divider of 1
    * Not use internal channel
    */
    ADC12_B_initParam initParam = {0};
    initParam.sampleHoldSignalSourceSelect = ADC12_B_SAMPLEHOLDSOURCE_SC;
    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);

    //Enable the ADC12B module
    ADC12_B_enable(ADC12_B_BASE);

    /*
    * Base address of ADC12B Module
    * For memory buffers 0-7 sample/hold for 64 clock cycles
    * For memory buffers 8-15 sample/hold for 4 clock cycles (default)
    * Disable Multiple Sampling
    */
    ADC12_B_setupSamplingTimer(ADC12_B_BASE,
      ADC12_B_CYCLEHOLD_16_CYCLES,
      ADC12_B_CYCLEHOLD_4_CYCLES,
      ADC12_B_MULTIPLESAMPLESDISABLE);

3- A12/mem1 init

//Configure Memory Buffer for valve current sense at A12 (port pin 9.4)
    ADC12_B_configureMemoryParam configureMemoryParam2 = {0};
    configureMemoryParam2.memoryBufferControlIndex = ADC12_B_MEMORY_1;
    configureMemoryParam2.inputSourceSelect = ADC12_B_INPUT_A12;
    configureMemoryParam2.refVoltageSourceSelect = ADC12_B_VREFPOS_AVCC_VREFNEG_VSS;
    configureMemoryParam2.endOfSequence = ADC12_B_NOTENDOFSEQUENCE;
    configureMemoryParam2.windowComparatorSelect = ADC12_B_WINDOW_COMPARATOR_DISABLE;
    configureMemoryParam2.differentialModeSelect = ADC12_B_DIFFERENTIAL_MODE_DISABLE;
    
    ADC12_B_configureMemory(ADC12_B_BASE, &configureMemoryParam2);


    ADC12_B_clearInterrupt(ADC12_B_BASE,
    	0,
    	ADC12_B_IFG1
    	);

    //Enable memory buffer 1 interrupt
    ADC12_B_enableInterrupt(ADC12_B_BASE,
      ADC12_B_IE1,
      0,
      0); 

  • 4- ADC ISR

    // ADC interrupt service routine
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=ADC12_VECTOR
    __interrupt void ADC_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(ADC12_VECTOR))) ADC_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
        switch(__even_in_range(ADC12IV , ADC12IV_ADC12IFG0 ))
        {
            case ADC12IV_NONE:
                break;
            case ADC12IV_ADC12OVIFG:
                break;
            case ADC12IV_ADC12TOVIFG:
                break;
            case ADC12IV_ADC12HIIFG:
                break;
            case ADC12IV_ADC12LOIFG:
                break;
            case ADC12IV_ADC12INIFG:
                break;
            case ADC12IV_ADC12IFG0:
                adcResult = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_0);            // Read ADC memory
                ADC12_B_clearInterrupt(ADC12_B_BASE, 0, ADC12_B_IFG0);
                break;
            case ADC12IV_ADC12IFG1:
                adcResultValve = ADC12_B_getResults(ADC12_B_BASE, ADC12_B_MEMORY_1);            // Read ADC memory
                ADC12_B_clearInterrupt(ADC12_B_BASE, 0, ADC12_B_IFG1);
                break;
            default:
                break;
        }
    }

  • How do you call ADC12_B_startConversion? That will tell us what CONSEQ and CSTARTADD are.

  • Oh! I missed to mention it.

    ADC12_B_startConversion(ADC12_B_BASE,
          ADC12_B_MEMORY_1,
          ADC12_B_SINGLECHANNEL);

    CSTARTADD is 2 after it is called.

  • You want to end up with CSTARTADD=1. (That probably means ADC12CTL3=1.)

    I think they want you to use " ADC12_B_START_AT_ADC12MEM1" rather than "ADC12_B_MEMORY_1", judging from (line 575):

    ti\msp430ware_3_80_06_03\driverlib\driverlib\MSP430FR5xx_6xx\adc12_b.h

**Attention** This is a public forum