Author Topic: TI F280041C PGA analog input  (Read 183 times)

0 Members and 1 Guest are viewing this topic.

Offline stoyanoff

  • Contributor
  • Posts: 12
  • Country: bg
TI F280041C PGA analog input
« on: July 04, 2020, 05:54:08 am »
Greetings! There is no answer from TI, so I need a little bit of help here! How can I select and convert data from one of the PGA inputs of F280041C? There is only 1 example into the lib -> pga_ex1_dac_adc_ext_loopback. So I`m using similar code, but I can`t get where I can change the read PGA input from. Here are parts my code:
Code: [Select]
#define MY_ADC_BASE ADCB_BASE
/*PGA enable I suppos*/
void initPGA(void)
{
    //
    // Set a gain of 3 to PGA2
    //
    PGA_setGain(PGA2_BASE, PGA_GAIN_3);

    //
    // No filter resistor for output
    //
    PGA_setFilterResistor(PGA2_BASE, PGA_LOW_PASS_FILTER_DISABLED);

    //
    // Enable PGA2
    //
    PGA_enable(PGA2_BASE);
}

/*ADCSOC init*/
void initADCSOC(void)
{
    //
    // Configure SOC0. The temperature sensor is internally connected to B14
    // and requires an acquisition time of at least 450 ns.
    //
    ADC_setupSOC(MY_ADC_BASE, ADC_SOC_NUMBER0, ADC_TRIGGER_EPWM1_SOCA,
                 ADC_CH_ADCIN1, 45);

    ADC_setupSOC(MY_ADC_BASE, ADC_SOC_NUMBER1,
                 ADC_TRIGGER_EPWM1_SOCA, ADC_CH_ADCIN1, 45);

    //
    // Set SOC0 to set the interrupt 1 flag. Enable the interrupt and make
    // sure its flag is cleared.
    //
    ADC_setInterruptSource(MY_ADC_BASE, ADC_INT_NUMBER1, ADC_SOC_NUMBER1);
    ADC_enableInterrupt(MY_ADC_BASE, ADC_INT_NUMBER1);
    ADC_clearInterruptStatus(MY_ADC_BASE, ADC_INT_NUMBER1);
}
/*my main loop*/
EPWM_enableADCTrigger(EPWM1_BASE, EPWM_SOC_A);
        EPWM_setTimeBaseCounterMode(EPWM1_BASE, EPWM_COUNTER_MODE_UP);
        ADC_forceSOC(MY_ADC_BASE, ADC_SOC_NUMBER0);
        ADC_forceSOC(MY_ADC_BASE, ADC_SOC_NUMBER1);
       //
       // Force ADC conversion
       //
       for(;;)
       {
           if(ADC_getInterruptStatus(MY_ADC_BASE, ADC_INT_NUMBER1))
                   {
                       //
                       // Acknowledge flag
                       //
                       ADC_clearInterruptStatus(MY_ADC_BASE, ADC_INT_NUMBER1);

                       dacResult = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER0);
                       pgaResult = ADC_readResult(ADCBRESULT_BASE, ADC_SOC_NUMBER1);
                       //pgaGain   = (float)pgaResult / (float)dacResult;

                       //
                       // Force ADC conversion
                       //
                       ADC_forceSOC(MY_ADC_BASE, ADC_SOC_NUMBER0);
                       ADC_forceSOC(MY_ADC_BASE, ADC_SOC_NUMBER1);
                   }
       }
In this case I`m receiving floating value for pgaResult and it doesn`t seem to change acording the value of any PGA input!
Any ideas?
Thanks!
 

Offline AkiTaiyo

  • Contributor
  • Posts: 5
  • Country: gb
Re: TI F280041C PGA analog input
« Reply #1 on: July 06, 2020, 12:25:23 pm »
I'm by no means a TMS320 expert but having a quick scan through the datasheet it looks like you need to sample the B9 input to get the output from PGA2. 
From your code it looks like both of your inputs are reading from ADC B1?
 

Offline stoyanoff

  • Contributor
  • Posts: 12
  • Country: bg
Re: TI F280041C PGA analog input
« Reply #2 on: July 08, 2020, 12:30:31 pm »
YEs!  I finally got it! It`s very strange. I thought the PGA_OUT are for outputting the measurend sygnal. It`s confusing, but now it makes sence!
Thanks!
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf