Discussion in "PIC Microcontroller Discussion" started by    sairfan1    Jul 4, 2013.
Thu Jul 04 2013, 06:29 pm
#1
Hi,

i want to generate 200KHz PWM from 16F877A or 16F887, kindly advise how is it possible, which crystal i have to use, no very high accuracy is required.

thanking you.
Sat Jul 06 2013, 10:11 am
#2
did you take a look at datasheet? how CCP module works? If not then download datasheet of 16F877A and look at chapter 8.0
It is fairly simple...
Sat Jul 06 2013, 01:15 pm
#3
thanks ajay, yes i read out datasheet also took some reference form book, i understand how to calculate time for timer 2, as this is my first time working for PWM module, i do not understand how do i calculate downwards to get 200KHz PWM, for example how to calculate period if 200KHz reqired, and duty percentage as well, plz help
Thu Jul 11 2013, 10:30 pm
#4
@ sairfan1
read this section book with examples
download book

http://snk.to/f-cdumgm9t
Tue Jul 16 2013, 11:27 am
#5

i do not understand how do i calculate downwards to get 200KHz PWM, for example how to calculate period if 200KHz reqired, and duty percentage as well, plz help

sairfan1


when you say 200Khz PWM then period is 1/(200 * 1000) = 5uS and duty cycle is your decision. if you want a pure square wave then duty cycle is 50% i.e. 2.5uS on and 2.5uS off time for output waveform.
 sairfan1 like this.
Tue Jul 16 2013, 12:39 pm
#6
thanks this was helpful to calculate required frequency, how can we calculate maximum PWM possible, for example i have 16F877A at clock 20MHz, how can i calculate maximum PWN can be generated
Wed Jul 17 2013, 11:13 am
#7
I told you to read chapter 8 of datasheet. Section 8.3.1 has equation to calculate PR2 value. If PR2 value is not coming into required range then you can adjust using TMR2 pre-scalar. for such a small time of 5uS you do not need to adjust TMR2 I believe. Try it let me know.
Wed Jul 17 2013, 12:42 pm
#8
thanks, its done.
Thu Jul 18 2013, 11:43 pm
#9
good job

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

KevinTab
Sun Apr 28 2024, 05:35 am
Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am