sbus icon indicating copy to clipboard operation
sbus copied to clipboard

Timer problems on Leonardo/Micro

Open ducktaperules opened this issue 6 years ago • 3 comments

it seems that i cant compile for Leonardo/Micro based on 32u4.

i get errors:

C:\...\libraries\sbus-master\sbus.cpp:104:5: error: 'TCNT2' was not declared in this scope

     TCNT2 = 0;

     ^

C:\...\libraries\sbus-master\sbus.cpp:112:5: error: 'TIFR2' was not declared in this scope

     TIFR2 |= 1 << OCF2A;

     ^

C:\...\libraries\sbus-master\sbus.cpp:112:19: error: 'OCF2A' was not declared in this scope

     TIFR2 |= 1 << OCF2A;

                   ^

After some research it seems that there is no timer 2 on the 32u4.

Is it possible to move this to another timer? If so which pins would we need to be used?

ducktaperules avatar Jul 24 '18 08:07 ducktaperules

I have the same issue. Tried changing to timer 1, it complied and put data out over UART but didn't change value with my controller

Then again I am a noob at software so lucky it even complied :)

Aaronsss avatar Jul 30 '18 17:07 Aaronsss

To fix the TIMER2 issue, change all the references to TIMER0. Validated for both the 328P and the 32u4, since both timers are 8-bit and have the same register definitions.

However, there is the issue of the lack of PCINT1_vect interrupt vectors on the 32u4 which I'm trying to resolve (PCINT1_vect and PCINT2_vect doesn't exist)

== UPDATE == Working on a updated version of the code... Hopefully will have time to request to push it back into the master branch later in the future...

ultimate1112 avatar Sep 22 '18 11:09 ultimate1112

@ultimate1112 thank you! Your fork works with MIcro/Leonardo, but the problem is, that delay, millis use the same timer 0 and this functions are broken... How can I use timer 3 or 4 on Micro for this library?

VICLER avatar May 05 '20 21:05 VICLER