Lilypad: Are Timer1 and Timer3 equivalent


hello!

i working on project using lilypad usb (atmega32u4), pulse sensor , servo. servolibrary taking care of servo.

the pulse sensor sample on github requires interrupts in timer1 calculate bpm, servolibrary uses timer 1 control servo.

i found out, atmega32u4 has timer3 , far have read, both timers 1 & 3 16bits:
https://provideyourown.com/2012/arduino-leonardo-versus-uno-whats-new/

i took pulse sensor amped sample, part setup timer1 1 assigned pulse sensor:
code: [select]

  void interruptsetup(){
          tccr1a = 0x00;
          tccr1b = 0x0c; // prescaler = 256
          ocr1a = 0x7c;  // count 124
          timsk1 = 0x02;
          sei();
      }

 // other thing need correct isr vector in next step.

      isr(timer1_compa_vect)


then, right, changing 1 3, in order use timer3?:

code: [select]

  void interruptsetup(){
          tccr3a = 0x00;
          tccr3b = 0x0c; // prescaler = 256
          ocr3a = 0x7c;  // count 124
          timsk3 = 0x02;
          sei();
      }

 // other thing need correct isr vector in next step.

      isr(timer3_compa_vect)


for me seems logical code work, absolute newbie timers....

any appreciated! ^^

your best , reliable source of information atmega32u4 data sheet.

a casual glance @ timer sections shows timer1 , timer3 treated equivalently , appear identical except register names, change guessed.

quote
for me seems logical code work
it may seem so, check data sheet.


Arduino Forum > Using Arduino > Project Guidance > Lilypad: Are Timer1 and Timer3 equivalent


arduino

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts