• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   5 Anonymous Users






Re: pwm
#5
版主
版主


查看用戶資訊
參照:
這是 201 ASP 裡的範例
Put CCP1 module in PWM mode, Configure CCP to clear DCB1 and DCB0 ( no Q cycles)

movlw 0x0C 這行會自己判斷 mode對嗎
     如果改成0x2c會如何呢
movwf CCP1CON
回覆:
因為 Q clock 有使用 <DCB1:DCB0> 做 PWM Duty 最低兩位元的比較,如果 DCB1:DCB0 = 00 ,的話就是 Timer2 的 Q clock 也必須為 00 時才能 match。這兩個位元就是用來擴展 PWN Duty Cycle 的解析度到 10-bit 的方式。但 Period 因為直接使用 PR2 暫存器所以 Period 只有 8-bit 的變化。
所以以公式來看的話 :
PWN Duty = CCLR1L (MSB) + DCB1 + DCB0 共10-bit
PWM Period = PR2 只有 8-bit
PWM 比較方式 : PR2 + Q clock (FOSC/4) : CCPR1L + <DCB1:DCB0>

發表於: 2008/1/10 11:40
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pwm
#4
初級會員
初級會員


查看用戶資訊
謝謝先進的回答我以明白pwm 算法
再此想再請教一個問題
這是 201 ASP 裡的範例
Put CCP1 module in PWM mode, Configure CCP to clear DCB1 and DCB0 ( no Q cycles)

movlw 0x0C 這行會自己判斷 mode對嗎
     如果改成0x2c會如何呢
movwf CCP1CON
----------------------

看不太明白這意思也??是自己會判斷還是如何呢??
bit 5-4 DC1B<1:0>: PWM Duty Cycle Least Significant bits
Capture mode:
Unused.
Compare mode:
Unused.
PWM mode:
These bits are the two LSbs of the PWM duty cycle. The eight MSbs are found in CCPR1L


發表於: 2008/1/9 22:33
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pwm
#3
中級會員
中級會員


查看用戶資訊
依你的敘述,我以16F684為例…
PWM Period =(PR2+1) * 4 * TOSC * TMR2 Prescale Value
已知
PWM Period = 64us, TOSC = 1 / 8MHz, TMR2 Prescale Value = 1
代入上述公式即可得到PR2 = 127,而
Duty Cycle Value = PR2 * 25% = 127 * 25% = 31.75
當然你也可以調整TOSC或TMR2 Prescale Value的設定值(1、4、16),來符合你的需求,只不過PWM的解析度也會因此而改變,更詳細的說明請參閱datasheet。以上說明,希望對你有幫助…

發表於: 2008/1/9 8:56
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pwm
#2
資深會員
資深會員


查看用戶資訊
我想應該是這樣子算的...
8MHz,內部頻率是8/4=2MIPS=0.5uS per instruction

b’01111111’ = 0x1F --> 計數 0~127 = 128

0.5 * 128 = 64uS

b’00011111’ = 0x1 F--> 計數 0~31 = 32

32 / 128 = 0.25 = 25%

發表於: 2008/1/9 8:48
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


pwm
#1
初級會員
初級會員


查看用戶資訊
你好:
請問該64uS .Duty Cycle 怎算出來的呢.有看datasheet...但他是根據什麼算出來還是不明白..煩請各位先進指導...謝謝


;Set up Period and Duty Cycle using an 8MHz oscillator
movlw b’01111111’
movwf PR2 ;Load a 64uS Period Value




movlw b’00011111’
movwf CCPR1L ; Load Duty Cycle Value
(25%) of PWM period

發表於: 2008/1/8 20:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------