Controlling MC33926 shield with 8-bit Timer

Hello,

I have a MC33926 motor driver shield and Arduino Uno. I’m trying to get the shield to work with an 8-bit timer. This paragraph here: pololu.com/docs/0J55/all#6.a suggests that is possible to use Timer0 to control the motors so I assume Timer2 will work as well as it is also 8-bits. As I am using the millis() function which I believe relies on Timer0, I’d prefer to use Timer2 for motor control (and free Timer1 for another library).

So my question is, what code modifications do I need to make to the MC33926 library (github.com/pololu/dual-mc33926-motor-shield) to get the motors to run on an 8-bit Timer? Are there any disadvantages using an 8-bit timer as opposed to a 16-bit one?

Thanks.

Hello.

You could use Timer2 to generate motor control signals. To get started doing that, you might consider looking at this post by Claire, and making changes to similar places in the MC33926 library to get it to work with other timers on the Uno. You could look at the ATmega328P datasheet to see what all of the timer registers do, and then you can set them up to be similar settings to those in our library. Alternatively, if you are not set on changing the library and using timers, you could also just not use the library and send PWM signals using the analogWrite() function.

One disadvantage of switching from a 16-bit timer to an 8-bit timer is that you would lose some motor speed resolution.

-Jon