Using timers for OOK coms and PWM on a 32u4?

Hi
I have a tiny 'Beetle' (by some called Bad USB) which is based on a 32u4 processor. It is (so far) programmed like a Leonardo. (Example)

In my project I will receive commands over an RF link using the ASK library in Radiohead.
This library uses Timer 1 internally, so using that for anything else is out of the question.

I plan to use D3 (marked SCL) and D11 as PWM outputs for motor control, but which timer is in use here?
I have seen some place, that one of those output can be controlled by either 8 or 16 bit timer. The other is fixed to 8 bit.

Due to the space available, larger boards like a Nano can not be used.

I already have made a PCB, but small corrections can be made, in case I should use some other PWM pin. Not all Arduino pins are in use.

Also, is it possible to 'tweek' AnalogWrite into using a different prescaler?
Motors might 'sing' if using the default 64 factor, while a factor of, say 4, would be outside my ears freqency range.
Or should I dig into the various registers directly?

Oops, forgot to mention that the two PWM outputs will NOT be active at the same time!

As they are both driving external FETs, I could go with one PWM output and 'something' to select one or the other.

Would any of this make things easier?

Hm, have found out that pin 3 and 11 are connected to Timer 0,
So either I should avoid using the various built-in timing routines (Delay, Micros etc), which I plan to anyway, or I should use some dual interrupt thing based on, say, Timer 4.

The later will give me better flexibility, but the PWM will not be all that precise due to interrupt handling. It will also put more load on the CPU.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.