Why does VirtualWire conflicts with PWM signal in Arduino/ATmega328 pin D10?

廉价感情. 提交于 2019-12-13 05:18:00

问题


After debugging a hardware prototype I'm making with an Arduino-like board and ATmega328, I noticed that the RF library VirtualWire disables PWM signal in pin D10. Why is that?

If I comment out the bit of code below, analogWrite (PWM) on pin D10 works again:

setup() {
  ...
  vw_set_rx_pin(2);
  vw_setup(2000);    // Bits per sec
  vw_rx_start();       // Start the receiver PLL running

  analogWrite(10, 180);
  ...
}

回答1:


VirtualWire uses CTC on timer 1 via OCR1A, which both completely disables PWM operation for OC1A (on D9) and OC1B (on D10) and prevents OC1A from operating freely. OC1B is still usable, but only in the modes prescribed by CTC at the rate programmed into the timer by VirtualWire.



来源:https://stackoverflow.com/questions/21069867/why-does-virtualwire-conflicts-with-pwm-signal-in-arduino-atmega328-pin-d10

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!