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.

TMS320 F28035 Experimenter Kit

Other Parts Discussed in Thread: CONTROLSUITE

Hello

I'm going to start with admitting that i am completely new with programing TI microcontrollers.

With that in mind I wanna connect a potentiometer to an Experimenter Kit and convert it in a PWM

Can some please share and example code in CSS for setting ADC A0 as an input for the potentiometer? I am using CCS v6.0.1

I want to know what registers to set and how and so on.. Now I know there is the Reference Guide for the microcontroller and I tried to work from there, but it's beyond my understanding.

Thank you!

  • Hello.

    Have you downloaded ControlSUIT ?

    If not, I strongly reccomend to do this. It contains LOTS of examples for LOTS of microcontrollers, for every peripheral device. Sure you'll find well commented ADC and PWM examples there ;)

  • Hello Disona,

    I did and i tried changing an example from there but again I wasn't able to fully understand what to change in order to read the ADC pin.
  • Ok, I'll try to help.

    Let's take this example: C:\ti\controlSUITE\device_support\f2803x\v130\DSP2803x_examples_ccsv5\adc_socsssssssssss

    ADC channel is configured here:

    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 = 2; //setup EOC2 to trigger ADCINT1 to fire
    AdcRegs.ADCSOC0CTL.bit.CHSEL = 4; //set SOC0 channel select to ADCINA4(dummy sample for rev0 errata workaround)
    AdcRegs.ADCSOC1CTL.bit.CHSEL = 4; //set SOC1 channel select to ADCINA4
    AdcRegs.ADCSOC2CTL.bit.CHSEL = 2; //set SOC2 channel select to ADCINA2
    AdcRegs.ADCSOC0CTL.bit.TRIGSEL = 5; //set SOC0 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC1CTL.bit.TRIGSEL = 5; //set SOC1 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 5; //set SOC2 start trigger on EPWM1A, due to round-robin SOC0 converts first then SOC1, then SOC2
    AdcRegs.ADCSOC0CTL.bit.ACQPS = 6; //set SOC0 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    AdcRegs.ADCSOC1CTL.bit.ACQPS = 6; //set SOC1 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)
    AdcRegs.ADCSOC2CTL.bit.ACQPS = 6; //set SOC2 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)

    At first you should know, that ADC operates in terms of SOCs (start-of-conversion). SOC is some kind of parameter set, that holds three things: 1 channel to be converterd, sample-and-hold window for that conversion, and a trigger, that will start conversion. So you can configure 16 different conversion, and every of them may be started at any time, independent from each other.

    In the code above 3 SOCs are configured. Let's skip first four lines (you can just copy them). The other 9 lines configure 3 SOCs. Let's take a look at one of them:

    AdcRegs.ADCSOC2CTL.bit.CHSEL = 2; //set SOC2 channel select to ADCINA2
    AdcRegs.ADCSOC2CTL.bit.TRIGSEL = 5;
    AdcRegs.ADCSOC2CTL.bit.ACQPS = 6; //set SOC2 S/H Window to 7 ADC Clock Cycles, (6 ACQPS plus 1)

    So, the first line actually selects ADC channel - what you cal a pin. It's written in ADC description, that CHSEL = 0 means chan. A0, CHSEL = 1 means chan. A1,
    and so on to CHSEL = 7 - chan A7. Then, CHSEL = 8 means chan. B0, CHSEL = 9 means B1 and so on.

    Next line is used to chose ADC start time. There are many options - you can start ADC conversion by software (set a special bit), you can start ADC conversion from a TIMER, and so on. Refer to ADC documentation. In this example TRIGSEL = 5 means that ADC conversion will start when EPWM1A timer will generate a Start-Of-Conversion signal. (You should configure EPWM1 to generate this signal).

    The last register ACQPS selects Sample-and-Hold window. It can't be less then 6, and there's allways added "1". So ACQPS = 6 means, that your signal will be samples for 6+1=7 cycles. After that a conversion will start (about 10-15 cycles). After conversion finishes and result is ready you will get an interrupt (first four lines of ADC configuration set this).

    Hope this will help.
  • Thank you very much for your help :)