Feature request - multiple OutputCompare


I need to output 3 signals synchronously at the same time with OutputCompare.
Studying what FEZ is doing with my oscilloscope I found that it is impossible.

There is always an offset between the signals that cannot be eliminated.
This offset depends on the buffer length.

So my suggestion is a new class MultiOutputCompare (or more understandable: MultiSignalGenerator)

Here some suggestions how this could be realized:

All output data should be specified in multiples of a base timing that is specified in microseconds.
The advantage is that the native code simply sets a timer to this base interval and so can easily output the data.

An elegant and intuitive class design would be:


new MultiSignalGenerator(int MAX_TIMINGS_BUFFER_SIZE);

Adding Pins:

MultiSignalGenerator.Add(Pin pin, bool initialValue, UInt32 Data);

Starting synchronous output:

MultiSignalGenerator.Start(UInt32 BaseTiming, bool bufferRepeating);

Lets say I want to output the following signals where each “0” and “1” has a duration of 100 us:

Pin 4: 110011
Pin 5: 011111
Pin 6: 111011

this could be easily done with the following code:

MultiSignalGenerator i_Generator = new MultiSignalGenerator(3);

UInt32[] u32_Data4 = new UInt32[] { 2, 2, 2 };
UInt32[] u32_Data5 = new UInt32[] { 1, 5 };
UInt32[] u32_Data6 = new UInt32[] { 3, 1, 2 };

i_Generator.AddPin((Cpu.Pin)FEZ_Pin.Digital.Di4, true,  u32_Data4);
i_Generator.AddPin((Cpu.Pin)FEZ_Pin.Digital.Di5, false, u32_Data5);
i_Generator.AddPin((Cpu.Pin)FEZ_Pin.Digital.Di6, true,  u32_Data6);

i_Generator.Start(100, false);

I think as you already have an OutputComapre class implemented it should not be very difficult to add this great feature.

You can also think about reducing memory consumption by replacing UInt32 buffers with UInt16 buffers
which allows to generate signals with a puls ratio of 1:65536 which should be enough for almost all use cases.

Thanks for considering it…


We will look into it but this can be done easily by you using “tasking” that is built in RLP.


As you say: “built in to RLP”, but not into C#.


Now 4 months have passed and I would like to know if the requested functionality has already been built in.


This will not be implemented as this is very application-specific and you can do it in RLP to fit your exact needs.


I completely disagree with you.

this is very application-specific

It is exactly as application-specific as OutputCompare.
It simply does exactly the same - just for more than one pin.

So if my suggestion is too application-specific, then OutputCompare is too application-specific, too!


Thanks for feedback. I see you already did this in RLP in another thread so you already see how it is possible to extend the firmware to whatever you need.


As there is no hope for a multiple OutputCompare for C# programmers, I uploaded my RLP project for all those who need a fast code that writes up to 8 pins simultaneously and synchronously.

It is more simple than my suggestion here, but enough for my current needs: