tmrtmrt/Fixes#2825_MEGA_2560_audio_output_not_working

This commit is contained in:
Tomaz Mertelj
2015-09-03 20:50:38 +02:00
parent 5e2fe112b0
commit a975d40ceb
2 changed files with 4 additions and 5 deletions
+2 -2
View File
@@ -62,7 +62,7 @@ void audioQueue::heartbeat()
else { else {
#if defined(CPUM2560) #if defined(CPUM2560)
if (toneFreq) { if (toneFreq) {
OCR0A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?). OCR4A = (5000 / toneFreq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
speakerOn(); speakerOn();
} }
#endif #endif
@@ -88,7 +88,7 @@ void audioQueue::heartbeat()
if (tone2TimeLeft > 0) { if (tone2TimeLeft > 0) {
#if defined(CPUM2560) #if defined(CPUM2560)
if (tone2Freq) { if (tone2Freq) {
OCR0A = (5000 / tone2Freq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?). OCR4A = (5000 / tone2Freq); // sticking with old values approx 20(abs. min) to 90, 60 being the default tone(?).
speakerOn(); speakerOn();
} }
#else #else
@@ -62,11 +62,10 @@ inline void boardInit()
OCR2A = 156; OCR2A = 156;
TIMSK2 |= (1<<OCIE2A) | (1<<TOIE2); // Enable Output-Compare and Overflow interrrupts TIMSK2 |= (1<<OCIE2A) | (1<<TOIE2); // Enable Output-Compare and Overflow interrrupts
// Set up Phase correct Waveform Gen. mode, at clk/64 = 250,000 counts/second // TIMER4 set into CTC mode, prescaler 16MHz/64=250 kHz
// (Higher speed allows for finer control of frequencies in the audio range.)
// Used for audio tone generation // Used for audio tone generation
TCCR4B = (1<<WGM42) | (0b011 << CS00); TCCR4B = (1<<WGM42) | (0b011 << CS00);
TCCR4A = (0b01<<WGM40); TCCR4A = 0x00;
#if defined (VOICE) // OLD FROM GRUVIN9X, TO REWRITE #if defined (VOICE) // OLD FROM GRUVIN9X, TO REWRITE
// SOMO set-up // SOMO set-up