-2
\$\begingroup\$

I am doing a project on pic16f877A to control dc motor speed control. I am working for the first time with pic microcontrollers . In my project i am generating pwm signals and to generate pwm pic uses timer2 . And i am also using serial communication and i read on google that timer2 is used for UART. so i wanted to know how pwm and uart will work together using single timer. I demonstrated the output on proteus and it works fine.

\$\endgroup\$
7
  • 1
    \$\begingroup\$ and i read on google that timer2 is used for UART Where exactly did you read that? UART has nothing to do with timers \$\endgroup\$ – m.Alin Mar 17 '15 at 16:17
  • \$\begingroup\$ i wanted to know how pwm and uart will work together using single timer Should work just fine provided you don't use the same pin for the UART rx/tx and the PWM output. \$\endgroup\$ – m.Alin Mar 17 '15 at 16:19
  • \$\begingroup\$ even i thought the same but the baudrate must be using the timer.Baudrate means bits per sec so ofcourse it needs timer to count for 1 sec \$\endgroup\$ – dcmotor Mar 17 '15 at 16:21
  • 1
    \$\begingroup\$ The baud rate generator is not using timers. \$\endgroup\$ – Eugene Sh. Mar 17 '15 at 16:22
  • \$\begingroup\$ yes, i am using different pin and my simulation result is perfect but since i read about uart using timer2 i had this dout. \$\endgroup\$ – dcmotor Mar 17 '15 at 16:22
4
\$\begingroup\$

You shouldn't believe everything you read on Google.

Your first port of call should always be the datasheet. In there it describes exactly how each peripheral works, and even gives you some simple block diagrams to follow so you don't need to understand all the terminology.

For instance, the UART section gives this nice diagram:

enter image description here

You can instantly see that the baud rate, generated by the SPBRG (Serial Port Baud Rate Generator) gets its clock direct from \$F_{OSC}\$ (the OSCillator Frequency) and there is no connection anywhere to any timer peripheral.

So I don't know what you read, or where you read it, but it may have been referring to some completely different chip, or have been written by someone who doesn't actually possess a clue.

\$\endgroup\$
2
\$\begingroup\$

"i read on google that timer2 is used for UART". Seriously!!? Design by heresay is not a good technique.

The proper source of information about any electronic device is its datasheet, and this case is no exception. The UART is very well described in the datasheet. It has it's own chapter 10 Addressable Universal Synchronous Asynchronous Receiver Transmitter starting on page 111. Section 10.1 on page 113 goes into great detail on the baud rate generator. There is also a complete diagram of the USART in section 10.2.2 on page 117 that shows, among other things, how the baud rate generator fits into the whole device. There is no dependence on timer 2 described anywhere in that chapter.

Once again, Read the Manual!

\$\endgroup\$
1
  • \$\begingroup\$ Actually I read the data sheet and was sure that timer2 has nothing to do with uart but I got confused with that google stuff \$\endgroup\$ – dcmotor Mar 17 '15 at 16:56

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.