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.

F28377D eCap APwm

Other Parts Discussed in Thread: CONTROLSUITE

Hi,

I have to control 8 rc servos position , I found an example in controlSuite ( ecap_apwm_cpu01 ) , I changed ECap1Regs.CAP1 and ECap1Regs.CAP2 registers to control movement of connected servo to GPIO-05 ( pin no 52 on docking station ) .


this is a part of my code :

   // Setup APWM mode on CAP1, set period and compare registers
   ECap1Regs.ECCTL2.bit.CAP_APWM = 1;	// Enable APWM mode
   ECap1Regs.CAP1 = 2500000; //0x01312D00;			// Set Period value
   ECap1Regs.CAP2 = 102000; //0x00989680;			// Set Compare value
   ECap1Regs.ECCLR.all = 0x0FF;			// Clear pending __interrupts
   ECap1Regs.ECEINT.bit.CTR_EQ_CMP = 1; // enable Compare Equal Int

   // Start counters
   ECap1Regs.ECCTL2.bit.TSCTRSTOP = 1;

ECap1Regs.CAP2 value range is from 102000 to 400000 .
my first question is am I in the right way to control a rc servo ?
my second question is how to control more servos with eCap module ?  I did not found anything like InitAPwm2Gpio to control next servo connected to GPIO-06 .

Best Regards,
Amir .

  • Hi Amir,

    This seems like a decent method of controlling these if you use a F28377D.

    As a note, you could also you the ePWM modules to do this (although depending on the PWM period you wish to output you may have to use the PWM clock prescaler, CLKDIV/HSPCLKDIV bits, to divide down the PWM).

    As you mention, there is only the one InitApwm function.  It outputs ECAP1's output signal to OUTPUTXBAR3 at GPIO5.  You can create functions for the other eCAP modules using a similar approach if you have some OUTPUTXBAR slots open. 


    Thank you,
    Brett