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/LAUNCHXL-F28069M: ADC TRIGGERED BY CPU TIMER 1

Part Number: LAUNCHXL-F28069M
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

Hi everyone, this is Mike

I want to ask about a way to trigger the ADC of the LAUNCHXL-F28069M with an interrupt of the CPU TIMER 1. I have read some of the threads here but I could not understand so much. I enabled the interrupts of the timer, It is working good, I have a LED Diode to see this interrupt. Then I changed the AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 2; but nothing happens, I disabled the EPWM module (this module was doing the interrupt in the ADC,I want to replace it by the CPU TIMER 1) I f you could give to me some hints about how to do the settings in order to trigger the adc with the CPU TIMER
Best regards
Mike

  • Mike,

    That is the correct approach.

    Are you servicing both the TIMER and ADC interrupts?

    Make sure that you really have TIMER1 enabled and not TIMER0.

    -Tommy

  • I have resolved this Tommy

    It was two things

    First the dumbest ... All my SOC 's registers were not correctly set. The second was more strange .. I wrote the code based on the controlsuite examples, I wanted to rewrite them to take some order and give the documentation of the code, So I moved some lines

    Originally, the were wrote like this:

    EALLOW; // Habilita la emulación de registros
    PieVectTable.ADCINT1 = &adc_isr; // El contenido del subprograma de interrupción "adc_isr" es copiado por el subprograma de interrupción "ADCINT1" contenido en la tabla.
    InitAdc(); // Inicializa el módulo del ADC
    AdcOffsetSelfCal(); // Ajuste de offset del ADC debido a su construcción
    (*Device_cal)(); // Ajuste de error de ganancia debido a la construcción del ADC
    PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// Habilita la Interrupción 1.1 en el Puerto de expansión de interrupciones
    IER |= M_INT1; // Habilita la interrupción 1 del CPU
    EINT; // Habilita las interrupciones globales
    ERTM; // Habilita las interrupciones en tiempo real
    EDIS; // Deshabilita la emulación de registros

    Then I moved them like this and it didn't worked


    EALLOW; // Habilita la emulación de registros
    /****** Inicialización y ajuste del ADC ***************/
    InitAdc(); // Inicializa el módulo del ADC
    AdcOffsetSelfCal(); // Ajuste de offset del ADC debido a su construcción
    (*Device_cal)(); // Ajuste de error de ganancia debido a la construcción del ADC
    /******************************************************/

    /***************** Interrupciones con el ADC **************************/
    PieVectTable.ADCINT1 = &adc_isr; // El contenido del subprograma de interrupción "adc_isr" es copiado por el subprograma de interrupción
    PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// Habilita la Interrupción 1.1 en el Puerto de expansión de interrupciones
    IER |= M_INT1; // Habilita la interrupción 1 del CPU
    EINT; // Habilita las interrupciones globales
    ERTM; // Habilita las interrupciones en tiempo real
    EDIS; //


    Right know I'm running the code as it was originalli write, then the settings of the Trigger = 2 (CPU TIMER 1) and it is running.
  • This approach ( the first written at beggining of the thread) can be used to trigger the adc by an external trigger (XINT done by GPIO input) ?

    Thanks Tommy
  • Tommy

    I'm servicing both interrupts (ADC, TIMER), is that ok?  Here it is how I am working the settings

    void adc_settings(void)
    {
    
        for(i=0;i<1001;i++)                     // Ciclo for para inicializar ADC_Buffer con un arreglo de 0's
        {
            ADC_Buffer[i]=0;
        }
        for(i=0;i<1001;i++)                     // Ciclo for para inicializar ADC_Buffer2 con un arreglo de 0's
          {
              ADC_Buffer2[i]=0;
          }
    
        EALLOW;                          // Habilita la emulación de registros
        /****** Inicialización y ajuste del ADC ***************/
        PieVectTable.ADCINT1 = &adc_isr; // El contenido del subprograma de interrupción "adc_isr" es copiado por el subprograma de interrupción "ADCINT1" contenido en la tabla.
        InitAdc();                       // Inicializa el módulo del ADC
        AdcOffsetSelfCal();              // Ajuste de offset del ADC debido a su construcción
        (*Device_cal)();                 // Ajuste de error de ganancia debido a la construcción del ADC
        /******************************************************/
    
        /***************** Interrupciones con el ADC **************************/
        PieCtrlRegs.PIEIER1.bit.INTx1 = 1;// Habilita la Interrupción 1.1 en el Puerto de expansión de interrupciones
        IER |= M_INT1;                   // Habilita la interrupción 1 del CPU
        EINT;                            // Habilita las interrupciones globales
        ERTM;                            // Habilita las interrupciones en tiempo real
        EDIS;                            // Deshabilita la emulación de registros
        EALLOW;                          // Habilita la emulación de registros
        conv=0;                          // Variable auxiliar que define, temporalmente, la longitud del Buffer
        AdcRegs.ADCCTL2.bit.ADCNONOVERLAP = 1; // Deshabilita el modo de sobrelapamiento de muestras
        AdcRegs.ADCCTL1.bit.INTPULSEPOS = 0;   // Control de pulso generador de interrupción -> 0 = Inicio de conversión, 1 = Un ciclo por resultado
        AdcRegs.INTSEL1N2.bit.INT1E = 1;       // Habilita ADCINT1
        AdcRegs.INTSEL1N2.bit.INT1CONT = 0;    // Modo de interrupciones continuas deshabilitado -> 0= Pulso generado si la bandera es limpiada por SW, 1=Pulso generado cada EOC
        AdcRegs.INTSEL1N2.bit.INT1SEL = 1;     // Final de conversion 1 (EOC 1) es el disparo (trigger) de ADCINT1
        AdcRegs.ADCINTSOCSEL1.bit.SOC0 = 0;    // Ningún ADCINT dispara un SOC, TRIGSEL define quien dispara SOC
        AdcRegs.ADCINTSOCSEL1.bit.SOC1 = 0;    // Ningún ADCINT dispara un SOC, TRIGSEL define quien dispara SOC
        AdcRegs.ADCINTSOCSEL1.bit.SOC2 = 0;    // Ningún ADCINT dispara un SOC, TRIGSEL define quien dispara SOC
        AdcRegs.ADCINTSOCSEL1.bit.SOC3 = 0;    // Ningún ADCINT dispara un SOC, TRIGSEL define quien dispara SOC
        /*********************************************************************/
    
    
        /************* Configuraciones del ADC ********************/
    
        AdcRegs.ADCSOC0CTL.bit.CHSEL = 0;      // Inicio de conversión 0 (SOC) para el canal ADCINA0 (pin 27)
        //AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5;    // ePWM 1 es el disparo para SOC1
        AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 2;    // CPU TIMER es el disparo de SOC1
        AdcRegs.ADCSOC0CTL.bit.ACQPS = 24;      // Ventana de Sample/Holding a 10 ciclos del reloj del ADC
    
        AdcRegs.ADCSOC1CTL.bit.CHSEL = 0;      // Inicio de conversión 0 (SOC) para el canal ADCINA0 (pin 27)
        //AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5;    // ePWM 1 es el disparo para SOC1
        AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 2;    // CPU TIMER es el disparo de SOC1
        AdcRegs.ADCSOC1CTL.bit.ACQPS = 24;      // Ventana de Sample/Holding a 10 ciclos del reloj del ADC
    
        AdcRegs.ADCSOC2CTL.bit.CHSEL = 0;      // Inicio de conversión 0 (SOC) para el canal ADCINA0 (pin 27)
       // AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 5;    // ePWM 1 es el disparo para SOC1
        AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 2;    // CPU TIMER es el disparo de SOC1
        AdcRegs.ADCSOC2CTL.bit.ACQPS = 24;      // Ventana de Sample/Holding a 10 ciclos del reloj del ADC
    
        AdcRegs.ADCSOC3CTL.bit.CHSEL = 0;      // Inicio de conversión 0 (SOC) para el canal ADCINA0 (pin 27)
        //AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 5;    // ePWM 1 es el disparo para SOC1
        AdcRegs.ADCSOC3CTL.bit.TRIGSEL = 2;    // CPU TIMER es el disparo de SOC1
        AdcRegs.ADCSOC3CTL.bit.ACQPS = 24;      // Ventana de Sample/Holding a 10 ciclos del reloj del ADC
    
       /* EPwm1Regs.ETSEL.bit.SOCAEN  = 1;        // Habilita inicios de conversión para el grupo A
        EPwm1Regs.ETSEL.bit.SOCASEL = 2;        // Inicio de conversión cuando CTR = PRDfrom CMPA on upcount
        EPwm1Regs.ETPS.bit.SOCAPRD  = 1;        // Pulso generado en el primer evento
        EPwm1Regs.TBPRD             = 4500;     // Periodo configurado a 10 KHz.
        EPwm1Regs.TBCTL.bit.CTRMODE = 0;        // Conteo en modo ascendente*/
        EDIS;                            // Deshabilita la emulación de registros
        /**********************************************************/
    
        asm(" EALLOW");                                  // Habilita la emulación de registros
        SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;   // Habilita TBCLK para que el módulo EPWM pueda trabajar
        asm(" EDIS");
    }
    
    void timer_settings(void)
    {
        EALLOW;
        PieVectTable.TINT1 = &cpu_timer1_isr;
        InitCpuTimers();
        ConfigCpuTimer(&CpuTimer1, 90, 1000);
        CpuTimer1Regs.TCR.all = 0x4000; // Usar instrucciones de SOLO LECTURA (write-only) para configurar el bit TSS = 0
        IER |= M_INT13;
    
        }

  • Mike,

    Since you reported that the interrupts are now working, I will not be reviewing the code.

    -Tommy
  • Good, Thanks
    It is working good