hacktorious wrote:I don't understand the params for the OutputCaptureEx command.
Both OutputCapture() and OutputCaptureEx() can generate an arbitrary waveform. You specify the waveform to be generated by giving the duration of the successive segments (high, low, high, etc.) of the desired waveform.
OutputCapture() is limited to generating the waveform on a specific pin, e.g. on the ZX-24 it is pin 27. OutputCaptureEx() is more flexible - it can generate a waveform on any output pin. It also has the ability to specify a repeat count so that the waveform specified by the segment duration array is repeated a number of times.
For OutputCaptureEx() the first parameter is the pin on which the waveform will be output. The second parameter refers to the array containing the segment duration values while the third parameter specifies how many segment duration values are in the array. The duration of each waveform segment is 67.8nS times the segment duration value, e.g. the value 10 specifies a duration of 678nS.
The fourth parameter is a set of flags that controls the generation process. Currently, only the least significant bit has meaning - it specifies whether the first waveform segment should be logic zero or logic one. Which value you should choose depends on the external circuitry that you are driving, particularly the idle state that it might need.
The fifth and last parameter is optional. If it is present, it is a "repeat count" that specifies how many times the data values in the array should be utilized. If you omit the fifth parameter, the data values are used just once and you get a waveform that corresponds to the duration values.
The capabilities of OutputCaptureEx() are exploited in OutBurst() by specifying duration of the equal-length high and low times of the square wave at the desired frequency (i.e. two equal segment duration values). Then, the iteration capability is used to repeat that one cycle a number of times so that the desired burst duration is achieved.
Does that help?