Using PWM peripheral to output fixed number of pulses

I am attempting to control 3x stepper motor drivers with a STEP + DIR inputs. For this I need to be able to create a pulse train with 50% duty cycle with a fixed number of pulses. It appears there should be a way to do this with the PWM peripheral (1 PWM per output). Timing and outputting the exact number of pulses is critical for this application.

My current plan is to setup 3x PWM peripherals with an appropriate COUNTERTOP, PRESCALER, and COMP values for the frequency and 50% duty cycle. On a stepper motor command, set SEQ[0].CNT to the number of pulse I wish to generate and start SEQ0. The SEQEND0 event will be used to notify the system the move has been complete.

I have a few questions:
1.) What is the best way prevent the EasyDMA from incrementing memory space for each PWM CNT (each pulse has the same duty cycle)?

2.) Should I use the SEQEND0_STOP Short to disable the PWM when the CNT is reached?

3.) Is there a way to read what the current count value while the PWM peripheral is running?

Note: Settings are being controlled directly through register writes

Thanks!

Parents Reply
  • Hi,

    jcondon said:
    Is there a way to read what the current count/repeats (i.e. how many pulses) the PWM has sent out while it's operating. Similarly is there a way to read out the number of pulses sent after STOP is issued?

    Looking at the PWM chapter in the Product Specification, the PWM peripheral does not support this. You set the number of pulses you want to send, and you get an event when that have completed.

    Maybe you could use a logic analyzer, and check that your FW implementation matches what you are trying to do with the logic analyzer.

Children
Related