1

I am new here and I know that this basic question has been answered in the past but what I want to know is this. And I cant figure out how to add this to one of those threads. Sorry in advance if I am posting this wrong.

Arduino Uno

I have a motor driven PWM off output 10 and output 9 is used for the display, can I change the resolution of output 10 only to 16 bit? or will both outputs need to be used as PWM when changing timer 2 to 16 bit? All of the coding samples I see are for changing both outputs.

  • I'm sorry, I'm not familiar with PWM libraries within the Arduino framework, but I've taken a look at the microcontroller datasheet, and it appears there is a way to operate 16-bit PWM on pin 9 (OC1A) while retaining normal port operation on pin 10 (OC1B). Please refer to table 20-4 on page 170 of the datasheet if you are willing to configure the timer manually. It is rather involving unfortunately. Perhaps there is a library for that. – ex-punctis Sep 24 '18 at 18:22
  • I think I agree with you, after reading the datasheet, therefore I will just rewire the board and not use output pin 9. If I get a little time I will do some testing with variations but for now I don't have the time. Thank you for the info! – user49780 Sep 26 '18 at 1:10
  • @user49780, read the updated answer from Gerben – Juraj Sep 27 '18 at 17:54
  • You mean “Timer 1”. Both outputs 9 and 10 are driven from Timer 1, not Timer 2. – Edgar Bonet Sep 27 '18 at 18:19
  • Yes, you are correct, I did mean timer 1. – user49780 Sep 28 '18 at 18:35
1

As long as you don't use PWM (i.e. analogWrite) on pin 9, any changes made to timer1 won't affect pin 9.

It will change both outputs, as both use the same (single) timer.

But you can use code to convert a 8-bit PWM value to a 16-bit value by simply multiplying the 8-bit value by 256.

  • The title is misleading. I don't think that the question was if you can have different PWM resolution on 9 and 10. I understand the question so that one of the pins 9 and 10 should be PWM and second a simple digital pin. (I am not the downvoter) – Juraj Sep 27 '18 at 17:39
  • @Juraj I think you might be right there. – Gerben Sep 27 '18 at 17:50
  • Some of the stuff I had read about changing the timer 1 to 16 bit mode made it sound like both pin 9 and 10 could only be used for PWM then. Of course this seemed incorrect but I could not find anything with a clear answer. I have since rewired the project to not use pin 9 in case it was true. I will sometime soon figure this out with some testing. Currently have little time for that. I do have a new issue that I am trying to figure out. It has to do with the scaling. It is not working as expected. But I will look more into it before starting a new thread if I can't figure that one out. – user49780 Sep 28 '18 at 18:44
  • The COM1A1 and COM1A0 bits in the TCCR1A enable PWM on pin 9. As long as you leave them at 0, pin 9 will act like a normal GPIO pin. – Gerben Sep 29 '18 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.