One thing that is making this harder to follow, as this logical thread has been winding through several threads, so unless you dig around you have no clue what the issues are.
That is Nick would like a lot of square waves all at different frequencies. With PWM you can only get about 13 or so unique PWM frequencies. That is several of the PWM pins share using the same clock, so restricts how many you can do easily.
Yes you can do it software wise, but that can be more complicated and probably not as accurate.
Again I don't know how much of a range of different square waves you need, are they fixed on each pin or do they vary...
But for example you could create a timer such as IntervalTimer, that if several of the pins were multiples of a common frequency you could have one timer try to handle multiple ones. where you keep a counter for each one, to know if you should update the state of a pin on a pin on this interrupt or not...
That is suppose you have 4 pins, that you can setup that you should change: 1 on every interrupt, 1 on every other, 1 on 3rd 1 on 4th...
you then have the interrupt handler do some simple logic like:
Code:
void timer_int() {
digitalInvertFast(pin0); // Note function does not exist but should)
static uint8_t cd1 = 2;
if (!(--cd1) {
digitalInvertFast(pin1); // Note function does not exist but should)
cd1 = 2;
}
static uint8_t cd3 = 3;
if (!(--cd2) {
digitalInvertFast(pin1); // Note function does not exist but should)
cd2 = 3;
}
...
}
Again this would not be perfect as there is logic makes slight delays...
But there are tricks. If all are on the same hardware GPIO port, you could setup masks
for each cycle through. For example you could maybe create an array of 4 items here that
has the InvertPins Mask for that port for each cycle through this list, so you increment, in this case
with 4 easily wrap around, and then simply store that array item into the Invert register...
But again this is easier for fixed things... But maybe could be done along the line Paul did with the
OctoWS2811... using DMA... But this is probably not for the feint at heart