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.

Starting ADC for F28335

Other Parts Discussed in Thread: TMS320F28335

 

Hi,

 

I have some difficulties with my senior university project so I need some help. I'm using the TMS320F28335 and here is my question. How can I make the SOC of ADC pushing the button connected, for example, to GPIO26?

 

Thanks!

 

  • You should review the TMS320x2833x, 2823x Analog-to-Digital Converter (ADC) Module Reference Guide (Rev. A) available on the TMS320F28335 Product Folder to understand the possible Start-Of-Conversion triggers available.  The illustration in Figure 1-4 shows the possible triggers for the SOC.  There is 1 GPIO/external trigger available which is possible (GPIO/XINT2_ADCSOC) and this is associated with GPIO8 or GPIO32 for ADC SOC A and GPIO10 or GPIO33 for ADC SOC B on the TMS320F28335.

    Otherwise, if you want to use an arbitrary GPIO, then the CPU will need to be involved to take an interrupt from this GPIO transition and then kick off a SOC via software.

  • Brandon, thanks for such useful link!

    Based on this reference I have written following code.

     

    #include "DSP2833x_Device.h"

     

    extern void InitSysCtrl(void);

    extern void InitPieCtrl(void);

    extern void InitPieVectTable(void);

    extern void InitAdc(void);

     

    void Gpio_select(void);

    interrupt void adc_isr(void);

    interrupt void xint2_isr(void);

     

    unsigned int voltage = 0;

     

    void main(void)

    {

    InitSysCtrl();

     

    DINT;

     

    Gpio_select();

     

    InitPieCtrl();

    InitPieVectTable();

     

    InitAdc();

     

    AdcRegs.ADCTRL1.bit.SEQ_CASC = 0;  

    AdcRegs.ADCTRL1.bit.CONT_RUN = 1;  

    AdcRegs.ADCTRL1.bit.ACQ_PS = 7;  

    AdcRegs.ADCTRL1.bit.CPS  = 0;  

    AdcRegs.ADCTRL2.bit.EXT_SOC_SEQ1 = 1;  

    AdcRegs.ADCTRL2.bit.INT_ENA_SEQ1 = 1;

    AdcRegs.ADCTRL2.bit.INT_MOD_SEQ1 = 0;

    AdcRegs.ADCTRL3.bit.ADCCLKPS = 3;

    AdcRegs.ADCMAXCONV.all = 0x0000;

    AdcRegs.ADCCHSELSEQ1.bit.CONV00 = 0;

     

    EALLOW;

    PieVectTable.ADCINT = &adc_isr;

    PieVectTable.XINT2 = &xint2_isr;

    EDIS;

     

    PieCtrlRegs.PIEIER1.bit.INTx6 = 1;

    PieCtrlRegs.PIEIER1.bit.INTx5 = 1;

     

    XIntruptRegs.XINT2CR.bit.ENABLE = 1;

     

    XIntruptRegs.XINT2CR.bit.POLARITY = 0;

     

    IER |= 1;

     

    EINT;

     

    ERTM;

     

    while(1)

    {    

    EALLOW;

    SysCtrlRegs.WDKEY = 0x55;

    SysCtrlRegs.WDKEY = 0xAA;

    EDIS;

    }

    } 

     

    void Gpio_select(void)

    {

    EALLOW;

     

    GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 0;

        GpioCtrlRegs.GPADIR.bit.GPIO26 = 0; 

        GpioCtrlRegs.GPAQSEL2.bit.GPIO26 = 0;

        GpioCtrlRegs.GPACTRL.bit.QUALPRD3 = 0x00;

    GpioIntRegs.GPIOXINT2SEL.bit.GPIOSEL = 26;

     

    EDIS;

    }

     

    interrupt void adc_isr(void)

    {

    voltage = AdcMirror.ADCRESULT0;

      AdcRegs.ADCTRL2.bit.RST_SEQ1 = 1;

      AdcRegs.ADCST.bit.INT_SEQ1_CLR = 1;

      PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

    }

     

    interrupt void xint2_isr(void)

    {

    PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;

    }

     

    Is everything right?

    While debugging I put a breakpoint inside xint2_isr(). I noticed that program stopped here twice, when I pushed the button. Why is it so? Is that ok?

  • Michael Henson said:

    While debugging I put a breakpoint inside xint2_isr(). I noticed that program stopped here twice, when I pushed the button. Why is it so? Is that ok?

    It is possible you are getting multiple transistions when you push the button which may cause multiple interrupts.  It looks like you are not modifying the GPIO26 settings to perform any input qualification to try to debounce the input.  You may want to tweak those settings to see if that results in better behavior.

  • Thanks for the response, Brandon! I have solved my problem.

    Best regards,

    Michael.