Go Down

Topic: Using Timer1 on Arduino Ethernet (Read 627 times) previous topic - next topic

Emmeran

Hi guys,

I want to use timer 1 for Arduino PCM as described in the playground (www.arduino.cc/playground/Code/PCMAudio) on my Arduino Ethernet while also using the Net features. Is that possible?

It uses non-inverting PWM on OC2A which apparently is pin 11 and therefore MOSI on SPI. My app didn't work. Does that mean it's not possible or is there maybe a way to change the pin to another.

Thx

Coding Badly


In startPlayback, I think changing this...

Quote
// Do non-inverting PWM on pin OC2A (p.155)
   // On the Arduino this is pin 11.
   TCCR2A = (TCCR2A | _BV(COM2A1)) & ~_BV(COM2A0);
   TCCR2A &= ~(_BV(COM2B1) | _BV(COM2B0));


...to this...

Quote
// Do non-inverting PWM on pin OC2B (p.155)
   // On the Arduino this is pin 11 (other timer 2 pin).
   TCCR2A = (TCCR2B | _BV(COM2B1)) & ~_BV(COM2B0);
   TCCR2A &= ~(_BV(COM2A1) | _BV(COM2A0));


...may switch the output to the other timer 2 pin.

Emmeran

Thx,  tried that (with TCCR2A tho, I believe that's a mistake on your side), but it didn't work.
Not on the Arduino Ethernet nor on the Uno.

Coding Badly

Thx,  tried that (with TCCR2A tho


To this?

Quote
TCCR2B = (TCCR2B | _BV(COM2B1)) & ~_BV(COM2B0);
    TCCR2B &= ~(_BV(COM2A1) | _BV(COM2A0));


Emmeran

Well no, sorry, that makes no sense.

The solution is this:
Code: [Select]
TCCR2A = (TCCR2A | _BV(COM2B1)) & ~(_BV(COM2B0) | _BV(COM2A1) | _BV(COM2A0));

plus (what I didn't do previously) changing all OCR2A's to OCR2B's.

Thanks anyways.

Go Up