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.

Basic ADC configuring question

Other Parts Discussed in Thread: TMS320F28027

Hello everyone!

 

I'm new using the DSP. I'm currently working with the TMS320F28027 piccolo, and i'm trying to use the ADCINB7 pin to read a signal.

According to the example provided by TI, adc_soc, i tried to use the ADCINB7, but i could'nt.

Can anybody help me with these? Here's the code i'm using, but i'm seeing no changes on the debugging, (animating), because the interrupt is never triggered.

 

#include "DSP28x_Project.h"     // Device Headerfile and Examples Include File

// Prototype statements for functions found within this file.
interrupt void adc_isr(void);
void Adc_Config(void);


// Global variables used in this example:
Uint16 LoopCount;
Uint16 ConversionCount;
Uint16 Voltage1[10];
Uint16 Voltage2[10];

main()
{

// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2803x_SysCtrl.c file.
   InitSysCtrl();


// Step 2. Initialize GPIO:
// This example function is found in the DSP2802x_Gpio.c file and
// illustrates how to set the GPIO to it's default state.
// InitGpio();  // Skipped for this example

// Step 3. Clear all interrupts and initialize PIE vector table:
// Disable CPU interrupts
   DINT;

// Initialize the PIE control registers to their default state.
// The default state is all PIE interrupts disabled and flags
// are cleared.
// This function is found in the DSP2802x_PieCtrl.c file.
   InitPieCtrl();

// Disable CPU interrupts and clear all CPU interrupt flags:
   IER = 0x0000;
   IFR = 0x0000;

// Initialize the PIE vector table with pointers to the shell Interrupt
// Service Routines (ISR).
// This will populate the entire table, even if the interrupt
// is not used in this example.  This is useful for debug purposes.
// The shell ISR routines are found in DSP2802x_DefaultIsr.c.
// This function is found in DSP2802x_PieVect.c.
   InitPieVectTable();

// Interrupts that are used in this example are re-mapped to
// ISR functions found within this file.
   EALLOW;  // This is needed to write to EALLOW protected register
   PieVectTable.ADCINT1 = &adc_isr;
   EDIS;    // This is needed to disable write to EALLOW protected registers

// Step 4. Initialize all the Device Peripherals:
// This function is found in DSP2802x_InitPeripherals.c
// InitPeripherals(); // Not required for this example
   InitAdc();  // For this example, init the ADC

// Step 5. User specific code, enable interrupts:

// Enable ADCINT1 in PIE
   PieCtrlRegs.PIEIER1.bit.INTx1 = 1;    // Enable INT 1.1 in the PIE
   IER |= M_INT1;                         // Enable CPU Interrupt 1
   EINT;                                  // Enable Global interrupt INTM
   ERTM;                                  // Enable Global realtime interrupt DBGM

   LoopCount = 0;
   ConversionCount = 0;

// Configure ADC
    EALLOW;

    AdcRegs.ADCCTL1.bit.INTPULSEPOS    = 1;    //ADCINT1 trips after AdcResults latch
    AdcRegs.INTSEL1N2.bit.INT1E     = 1;    //Enabled ADCINT1

    AdcRegs.INTSEL1N2.bit.INT1CONT  = 0;    //Disable ADCINT1 Continuous mode   

    AdcRegs.INTSEL1N2.bit.INT1SEL    = 1;    //setup EOC1 to trigger ADCINT1 to fire

    AdcRegs.ADCSOC0CTL.bit.CHSEL     = 0xF;    //set SOC0 channel select to ADCINB7

    AdcRegs.ADCSOC0CTL.bit.TRIGSEL     = 6;    //start trigger on EPWM1, ADCSOCB   
    AdcRegs.ADCSOC0CTL.bit.ACQPS     = 6;    //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    EDIS;

// Assumes ePWM1 clock is already enabled in InitSysCtrl();
  
   EPwm1Regs.ETSEL.bit.SOCBEN    = 1;        // Enable SOC on B group
   EPwm1Regs.ETSEL.bit.SOCBSEL    = 4;        // Select SOC from CPMA on upcount
   EPwm1Regs.ETPS.bit.SOCBPRD     = 1;        // Generate pulse on 1st event
   EPwm1Regs.ETCLR.bit.SOCB = 1;       // Clear SOCB flag
  
   EPwm1Regs.CMPA.half.CMPA     = 0x0080;    // Set compare A value
   EPwm1Regs.TBPRD                 = 0xFFFF;    // Set period for ePWM1
   EPwm1Regs.TBCTL.bit.CTRMODE     = 0;        // count up and start

// Wait for ADC interrupt
   for(;;)
   {
      //LoopCount++;
   }

}


interrupt void  adc_isr(void)
{

  Voltage1[ConversionCount] = AdcResult.ADCRESULT0;
 
  // If 20 conversions have been logged, start over
  if(ConversionCount == 9)
  {
     ConversionCount = 0;
  }
  else ConversionCount++;

  AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1;        //Clear ADCINT1 flag reinitialize for next SOC
  PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;   // Acknowledge interrupt to PIE

  return;
}

  • Felipe,

    The ADCINT1 is set to trigger off of EOC1 instead of EOC0. If you change your code to the below, I think this will solve this issue.

    AdcRegs.INTSEL1N2.bit.INT1SEL = 0; //setup EOC0 to trigger ADCINT1 to fire

     

    Regards,

    Nicholas Smith

     

  • Nicholas,

     

    Thanks for your answer. It did solve the problem of the interrupt generation, but i'm still seeing something i' don't understand. After the change you suggest, i tried with the same code, changing the AdcRegs.ADCSOC0CTL.bit.CHSEL. When i use 0xD for the ADCINB5 and 0x8 for the ADCINB0, i get values near 0 in the AdcResult.ADCRESULT0, always.

    Also, with the ADCINB7, (0xF in AdcRegs.ADCSOC0CTL.bit.CHSEL), i see only noise, with values near 3750 in the AdcResult.ADCRESULT0. Is there any hardware additional change i have to do? Or do i have a software mistake?

    It's strange 'cause selecting ADCINB1 - ADCINB4 and ADCINB6 on that code works fine. I'm using a potentiometer very big and at the debug i see how the values of the conversion change according to the position of the potentiometer, from 0 to 4095. I have the potentiometer conected to the ground and 3.3V pins on the docking station, and the middle is conected to the ADCINBx pin.

    Thanks in advance!

    Felipe.

  • Sorry,

     

    I've been reading the datasheet of the tms320F28027 and now i know i really can't use ADCINB0 and ADCINB5. I suppose i've got to configure some mux to use the ADCINB7 in the appropiate way. I'll be looking that, but if you can help me i would really appreciate..

     

    Thanks in advance!

    Felipe.

     

  • Felipe,

    If you are using the F28027 controlCARD one useful thing to note is that there is a switch (SW4) that controls the pinout of ADC-B0 and ADC-B7.  Please see the schematics of the F28027 controlCARD.  By default the pin labeled "B0" on the Experimenter's Kit will actually connect to the F28027's ADC-B7 pin.  This may solve some of the confusion you are seeing.  Feel free to edit the state of the switch if you desire.


    Thank you,
    Brett Larimore

  • Brett,

     

    Thank you very much. I edited the state of the switch and ADCINB7 worked perfectly.

     

    Regards,

    Felipe.