Triggering the FlexPWM

DrM

Well-known member
Hi,

Is there a way to start a FlexPWM module or submodule from an interrupt, at the hardware level?

By that, I mean without using an ISR. But rather, an edge on a pin causes the flexpwm to start through some internal configuration of the mcu.

If so, could somebody please show a code snippet how to do it?

Thank you
 
Last edited:
Well, the FlexPWM is setup already to generate a particular pulse train.

At present, there is an ISR that is attached to a digital I/O pin interrupt. The ISR starts the FlexPWM.

The mission is to try to take the ISR out of the picture and just have the hardware do it directly.

What brings me to ask the question, is because I recall there is mention in the reference manual for starting the FlexPWM from an interrupt.

The manual being what it is, it can easily be a big time saver to just ask if somebody already knows how to do this.

If you are interested in the larger context, here is the project:

https://github.com/drmcnelson/TCD1304-Sensor-Device-with-Linear-Response-and-16-Bit-Differential-ADC
 
P/S The Teensy 4 (and 4.1) is the only board that I know of in this class of devices that can do this. And as it turns out, the commercial offerings many of which use FPGA's for timing, are not doing it very well either. So, this seems like a nice kudo for the T4.
 
One more P/S, doing the trigger start this way, versus an ISR, is not a show stopper. For a 10ms exposure time, a 100nsecs is not a big deal and as long as the jitter is low, it can be managed one way or another anyway. I feel it would be a little more professional to do it the "right" way if we can.
 
There's several external inputs available to the FlexPWM modules via the xbar, which means they can be connected directly to GPIOs or triggers from other modules... but which one to use really depends on the specific of how the FlexPWM is being used: is it just being used as a one-shot timer, does it get started manually and then run forever, does it need to be manually restarted...
 
The only thing I see in the manual that looks like it might work is the FORCE capability. FRCEN enables initialization from a FORCE_OUT event. FORCE_SEL lets you assign an external signal as the source of the FORCE_OUT event, which initializes the FlexPWM's counter. The thread below discusses use of these capabilities to synchronize channels, but perhaps you could use it to start whatever it is you have the PWM doing.

As @jmarsh said, It would help to know what you are doing with the FlexPWM, and also what you do in the ISR that starts it.

 
@jmarsh

I did not know that the FlexPWM can be run as a one shot. That would be super useful.

Any way for the the submodule in question, it would be good to just start the submodule and have it run until something else stops it.

@joepasquariello

I have not yet succeeded in starting a submodule from force. it seems like no matter what I do, it starts only when run is set.
 
Attached is code for the application.

This is a header-only library from the above repo. It operates a TCD1304 (linear CCD) using the FlexPWM and to read the analog signal it uses either a 16 bit ADC or the T4's 12bit input. The circuity outside the T4 is described in the readme for the repo.

For the question at hand:

Please see setup_timer() at line 1971, and see timer_start() at line 1939.

At present, timer_start() is attached to a digital i/o pin interrupt. The mission is to start the timer directly from the pin.

After that,

The next think we could improve is that the interrupt from the timer is used to start a pulse sequence for the tcd1304. See setup_pulse() at line 1168, and pulse_start() at line 1076. SImilar to above, pulse_start() is called from an ISR, in this instance it is attached to the timer.

Having the timer start the pulse sequence directly would be icing on the cake.
 

Attachments

  • TCD1304Device2.h
    94.4 KB · Views: 17
P/S

I forgot to mention, very important. There is another application that I would like to use this capability for.

If we can get the interrupt latency or at least the jitter down to 100ns or preferably 10nsec-ish (1/150MHz), for launching a flexpwm submodule, or module, then we can have a super nice programmable gate and delay generator for use in a lab.
 
Okay, so, after re-perusing the manual again, it seems like there is no way to cold start a flexpwm submodule from a pin interrupt except by using an ISR.
 
Back
Top