I would like to have both Auduino and IllutronB on the same device, and use the same pin for audio out.
The synths will not be running at the same time, so no mixing, but I only have one pin available.
IllutronB uses Timer 0, on pin 6 (and 5 for separated channels)
Auduino uses Timer 2, on pin 3
Has anyone tried to change this?
My device now has audio out on pin 6, for the IllutronB, so the best for me would be to "move" Auduino to that pin.
I have little understanding of Timer interrupts, but since they are both 8 bit timers, could I change the Auduino code to use
Timer 0 A, in stead of the TImer 2 B it uses originally?
I have tried some different ways now
I thought I got it right, but I get a compile error
void audioOn() {
// Set up PWM to 31.25kHz, phase accurate
TCCR0A = _BV(COM0A1) | _BV(COM0B1) | _BV(WGM00);
TCCR0B = _BV(CS00);
TIMSK0 = _BV(TOIE0);
}
As far as I can see, this is the way to set phase accurate on Timer0
But I get the error:
core.a(wiring.c.o): In function __vector_16': C:\Program Files\arduino-1.0.5\hardware\arduino\cores\arduino/wiring.c:49: multiple definition of __vector_16’
Auduino_pin6.cpp.o:C:\Program Files\arduino-1.0.5/Auduino_pin6.ino:138: first defined here
As I understand, it doesn’t like me using Timer0
What does this line do? #define PWM_INTERRUPT TIMER0_OVF_vect
because if I change it to …Timer0_OVF_vect, it compiles
I have looked at it closer, and it looks like IllutronB uses both Timer1 and 0
Timer0 is used for PWM output, so I guess it doesn't come in conflict with the Delay()
Would it be possible to use Timer0 as output for Auduino as well?
That way I can have the same audio output pin6 for both in the hardware
It would be very simple to put the auduino code inside the illutron and switch between the two using a push button.
The Auduino does not know or care which pin its output goes to so just use whichever one the illutron uses.
The easiest way to do this would be to have
Loop()
If auduino pin is high
Auduinoloop
Esle
Illutronloop
And do the same in the isr
Isr
If auduino pin is high
Auduinoisr // change the output pin to match illutron
Else
Illutronisr
This way you have very little code to change, you can even keep the setup function exactly as it is on the illutron, this will work provided you remember to change the auduino isr to use the same pin as illutron
Rushed explanation, getting family ready to go camping, hopefully makes some sense to you ?