Pages: [1]   Go Down
Author Topic: Using Timer1 on Arduino Ethernet  (Read 574 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 206
Posts: 12853
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 206
Posts: 12853
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thx,  tried that (with TCCR2A tho

To this?

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

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well no, sorry, that makes no sense.

The solution is this:
Code:
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.
Logged

Pages: [1]   Go Up
Jump to: