Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
版主
|
曾老師的書沒有錯,書上是使用 External 32768Hz Crystal 當作輸入源,所以選用 T1_SOURCE_EXT 來當作計時器的來源,且每 0.5 秒中斷一次的。
發表於: 2009/9/23 17:37
|
|||
|
Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
初級會員
|
感謝版主熱心幫我看程式
沒有想到是書上OpenTimer1的地方參數給錯了 我再去測看看SPI是否能正常收到資料進入中斷 有問題再來請教 謝謝
發表於: 2009/9/23 17:05
|
|||
|
Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
版主
|
"T1_SOURCE_EXT & // 並開啟TIMER1中斷功能(PIE1bits.TMR1IE=1)"
錯了,System Clock 沒進到 Timer1,Timer1 怎會動作? 改成 T1_SOURCE_INT &
發表於: 2009/9/23 12:27
|
|||
|
Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
版主
|
程式裡缺了些東西如下紅字所示,建議參考一下 W401 裡的練習5-2
RCONbits.IPEN = 1; PIR1bits.TMR1IF=0 ; //清掉Timer 1 中斷旗號 PIE1bits.TMR1IE=1; // 打開 Timer1 中斷 IPR1bits.TMR1IP = 1; //INTCONbits.PEIE = 1; // 開啟周邊中斷功能 //INTCONbits.GIE = 1; // 開啟全域中斷控制 INTCONbits.GIEH = 1;
發表於: 2009/9/18 14:23
|
|||
|
Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
初級會員
|
多謝版主的熱心回覆
我改過以後一樣是進不了中斷 昨天晚上我剛好也去找了版主說的教育訓練來看 希望對C18的撰寫上有幫助 仔細研究了中斷的部分 結果問題還是一樣 我後來把他改成開啟中斷優先序的功能 希望中斷程式進入點比較不會有問題 但還是進不了中斷 ================================== //宣告並安排中斷執行程式記憶體位置 #pragma code high_vector=0x08 void high_interrupt (void) { _asm GOTO timer1_isr _endasm } #pragma code #pragma interrupt timer1_isr ================================== RCONbits.IPEN = 1; IPR1bits.TMR1IP = 1; //INTCONbits.PEIE = 1; // 開啟周邊中斷功能 //INTCONbits.GIE = 1; // 開啟全域中斷控制 INTCONbits.GIEH = 1;
發表於: 2009/9/17 17:02
|
|||
|
Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
版主
|
有關 PIC18 的中斷,建議看一下 W401 教育訓練的第五章,那裏說的很清楚。
發表於: 2009/9/17 11:13
|
|||
|
Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
版主
|
你把 PIC18 的中斷功能當成PIC16F 來用,所以中斷的進入向量點就不對了。
ROCN<IPEN> 為 0 ; 中斷進入點為 0x0008 RCON<IPEN> = 1; 分高低優先權中斷 0x0008 & 0x0018 所以請將程式中斷改為: #pragma code low_vector=0x0008 void low_interrupt (void) { _asm GOTO timer1_isr _endasm } #pragma code
發表於: 2009/9/17 10:51
|
|||
|
Re: PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
初級會員
|
我拿了書上Timer中斷的程式做測試
結果連Timer的中斷都無法正常進入 中斷的Flag bit 也都沒有反應 可以請各位板友幫幫忙嗎? 以下是測試的程式
================================
發表於: 2009/9/16 22:36
Edited by Ryang on 2009年09月17日 10:40:35
|
|||
|
PIC18的SPI進不了中斷的問題
|
||||
---|---|---|---|---|
初級會員
|
最近在學習利用SPI做dsPIC33F 與PIC18之間做資料傳輸
我參考了下載中心中有一份用兩塊dsPIC30F 一塊當MASER 一塊當SLAVE把自己模擬成EEPROM 中間利用SPI做資料的儲存與存取的範例程式 我把MASTER的程式改成dsPIC33F可用的 再把SLAVE的程式改成PIC18可用的 但在測試過程中 MASTER感覺是正常運作的 但SLAVE端都沒有收到任何資料 也不會進SPI的中斷 可否請幫忙看看程式中的中斷設定是否正確 謝謝 Attach file: Link only for registered users
發表於: 2009/9/16 17:45
|
|||
|