• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: ccp2 不能工作
#5
新會員
新會員


查看用戶資訊
Dear Sir
相關之程式如下:

RCONbits.IPEN = 1; // interrupt priority enable
INTCONbits.GIEH = 1;// enableHi priority
INTCONbits.GIEL = 1;// enable Lo priority



void InitCCP1CCP2(void)
{
// Configure Timer3
OpenTimer1(TIMER_INT_OFF&T1_16BIT_RW&T3_SOURCE_INT);
// Configure Timer3
OpenTimer3(TIMER_INT_OFF&&T3_16BIT_RW&T1_SOURCE_INT&T1_CCP1_T3_CCP2);

//CCP interrupt Priority setting
IPR1bits.CCP1IP = 0; // Low priority
IPR2bits.CCP2IP = 0; // Low priority

//CCP clear interrupt flag
PIR1bits.CCP1IF = 0; // clear CCP1 interrupt flag
PIR2bits.CCP2IF = 0; // clear CCP2 interrupt flag

// Configure Capture1
OpenCapture1(C1_EVERY_RISE_EDGE & CAPTURE_INT_ON); //

// Configure Capture2
OpenCapture2(C2_EVERY_RISE_EDGE & CAPTURE_INT_ON);//

}


void LoIntService(void)
{

if(PIR1bits.CCP1IF)
{
TMR1H=0; // Clear out timer registers
TMR1L=0;
CCP1CONbits.CCP1M0 =!CCP1CONbits.CCP1M0;
PIR1bits.CCP1IF = 0;
((XYDATA*)msd_buffer)->MotionData[RecIndex].X_Lo = CCPR1L;
((XYDATA*)msd_buffer)->MotionData[RecIndex].X_Hi = CCPR1H;

}
if(PIR2bits.CCP2IF)
{

TMR3H=0; // Clear out timer registers
TMR3L=0;
PIR2bits.CCP2IF= 0;
((XYDATA*)msd_buffer)->MotionData[RecIndex].Y_Lo = CCPR2L;
((XYDATA*)msd_buffer)->MotionData[RecIndex].Y_Hi = CCPR2H;
}

}
使用的是C18 lib
Configuration bits ccp2 Mux 也確定設為RC1
RC1 確定有訊號輸入且為 Hi 時
debug 可看出TRISCbits.TRISC1 = 1
但是 PORTCbits.CCP2 卻還是 Lo
當然沒有interrupt
更換IC還是一樣
是否有遺忘哪些設定
請指正
謝謝

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


Re: ccp2 不能工作
#4
版主
版主


查看用戶資訊
看不出來為什麼 CCP2 的 Capture 為什麼從 RC1 輸入會失敗,所以要在確定 CCP2MX of Configuration 3H 的設定沒錯?

CONFIGURATION REGISTER 3 HIGH (CONFIG3H: BYTE ADDRESS 300005h)

bit 0 CCP2MX: CCP2 Mux bit
1 = CCP2 input/output is multiplexed with RC1
0 = CCP2 input/output is multiplexed with RB3

不確定是否使用 C18 所提供的 LIB,還是直接使用暫存器的設定方式,C18 已經是千鎚百鍊了因該在這一點上應該是不會錯的。

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


Re: ccp2 不能工作
#3
新會員
新會員


查看用戶資訊
Dear Ryang
對不起 忘了告訴ic編號
是PIC18F452

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


Re: ccp2 不能工作
#2
版主
版主


查看用戶資訊
先講一下,你用哪一顆PIC18F? 元件有些差異的。

發表於: 2008/8/11 17:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


ccp2 不能工作
#1
新會員
新會員


查看用戶資訊
大家好
請教大家我使用 c18
執行ccp1 capture mode 抓取duty cycle 一切都沒問題
但是改為 ccp2 由RC1接收訊息 則一點動靜都沒
似乎RC1沒收到訊號
Configuration bits ccp2 Mux 也設為RC1
請問到底哪裡沒設定或是 C18版本不對

謝謝

發表於: 2008/8/9 0:05
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... ]

教育訓練中心

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