Hello
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:
Constructor:
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);
Example:
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…
Elmü