• slider image 442
  • slider image 497
  • slider image 498
  • slider image 499
  • slider image 500
  • slider image 502
:::


Browsing this Thread:   1 Anonymous Users






Re: 使用pic16f917 的ccp模組
#2
中級會員
中級會員


查看用戶資訊
我使用過 pic16f877, 看了一下資料發現兩個可說是相同的.
提供以下給你參考!

CCP2與CCP1是相同的, 單純只是一個模組或兩個模組的差別.

你所提到的與 TMR2 中斷有關,
但仔細看資料手冊的敘述, 應該只是避免最先產生的脈波責任週期錯誤而已.
其它的連續輸出與 TMR2 中斷並沒有關係.

如果不考慮最先產生的脈波責任週期會有錯誤的話, 大概如下:

BANKSEL   PIE1
  BCF       PIE1
,1      TMR2IE TIMER2 不中斷
  BANKSEL   PIR1        
清除 TMR2IF
  BCF       PIR1
,1      ; (有沒有都可以反正不中斷了)

  
BANKSEL   TRISC
  BCF       TRISC
,5
    
  BANKSEL   PR2
  MOVLW     0FFH
  MOVWF     PR2         
設定 PWM 頻率週期 

  BANKSEL   CCPR1L
  MOVLW     80H         
設定責任週期的數值
  MOVWF     CCPR1L      
責任週期 CCPR1L PR2

  MOVLW     0CH         
設定 CCP1 模式為 1100 PWM 輸出 )
  
MOVWF     CCP1CON     暫不使用 CCPxxCCPxY使其為 0

  BANKSEL   T2CON
  CLRF      T2CON       
TMR2 預除值為 1
  BSF       T2CON
,2     TMR2ON 為 1開始執行

  BANKSEL   TRISC
  BCF       TRISC
,5     CCP1 腳開始 PWM 結果的輸出     

;****************************     
  
BANKSEL   TRISD
  BCF       TRISD
,2

;  BANKSEL   PR2         因為 CCP1CCP2 皆關聯 TMR2
;  MOVLW     0FFH        所以 PWM 頻率週期 是一樣的
;  MOVWF     PR2         無法作兩個頻率週期不一樣的輸出
;                        ; 只能做出 不一樣的責任週期

  BANKSEL   CCPR2L
  MOVLW     50H         
設定責任週期的數值
  MOVWF     CCPR2L      
責任週期 CCPR2L PR2

  MOVLW     0CH         
設定 CCP2 模式為 1100 PWM 輸出 )
  
MOVWF     CCP2CON     暫不使用 CCPxxCCPxY使其為 0

;  BANKSEL   T2CON      TMR2 在前面已經令其開始執行了,
;  
CLRF      T2CON      所以這裡的就可以不需要了
;  BSF       T2CON,2

  BANKSEL   TRISD
  BCF       TRISD
,2     CCP2 腳開始 PWM 結果的輸出


以上給你做參考!

發表於: 2007/11/17 10:36
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


使用pic16f917 的ccp模組
#1
中級會員
中級會員


查看用戶資訊
請問大家


關於pic16f917它內部有兩組pwm產生模組 它是配合tmer2中

斷使用,我想請問大家,datasheet裡面介紹到ccp1如何產生

pwm脈波,卻沒介紹ccp2如何產生,請問大家是否認為,兩個

ccp模組其實功能是一樣的呢? 或者沒這麼單純使用?

另外請教 我怎麼開timer2模組功能? 我自己設好的一些中斷設

定卻都沒把timer2中斷打開,只要能夠打開,我想就可以將兩

組pwm訊號個別打出來使用了,謝謝大家回應。

發表於: 2007/11/16 17:36
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... ]

教育訓練中心

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