0

I want to make a device with a TFT screen and a speaker that uses the builtin tone() function. However, according to the documentation, using tone() interferes with PWM on pins 3 and 11. On the Arduino Uno, the MOSI pin is default on pin 11, and it seems like defining another pin for MOSI disables hardware SPI, which, according to the module page, slows down the device. As well, the examples are written for hardware SPI and the SD card is only available with hardware SPI. What should I do here? Is there a way to redefine the default MOSI pin without disabling hardware SPI?

asked Dec 4, 2018 at 23:18
2
  • It is no problem. The tone function uses timer2 which is the same timer when using pwm for pin 3 and 11. The tone function does not interfere with pin 3 and 11, it only uses timer2 for a software interrupt to create a tone on any pin. The tone function does not use the pwm capabilities of the microcontroller. Commented Dec 4, 2018 at 23:42
  • short version : "interference with PWM", not with SPI Commented Dec 5, 2018 at 6:26

1 Answer 1

1

You are getting your wires crossed in your brain and imagining a problem where there is none.

Both PWM on pins 3 & 11, and tone(), use the Timer2 device. Only one of those can use Timer2 at a time, and they both want to use it in different ways, so there is a conflict between them.

Timer2 has nothing to do with SPI. So tone() has no effect on SPI, and nor does PWM have any effect on SPI (other than the fact that only one can come out of pin 11 at any time), since there is no internal resource conflict.

answered Dec 5, 2018 at 0:04

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.