• slider image 442
  • slider image 477
  • slider image 479
  • slider image 480
  • slider image 481
  • slider image 482
:::


Browsing this Thread:   1 Anonymous Users






Re: 12F675使用GPIO變化中斷 HI-TECH C 9.65版
#5
資深會員
資深會員


查看用戶資訊
參照:

sakanayy 寫道:

#include <pic.h>

__CONFIG (INTIO & PROTECT & WDTDIS & MCLRDIS & CPD & BOREN & PWRTEN );

void interrupt isr_yy ( void );

void main( void )
{
RP0=1;
TRISIO=0x00;
RP0=0;
CMCON=0x07; //關閉比較器
GPIO=0; //CLEAR GPIO
RP0=1;
IOCB=0x10;
ANSEL=0x00;
TRISIO=0x10;
OSCCAL=0x80; //111111XX~000000XX
INTCON=0xC8; //GPIE=1,GIE=1
RP0=0;
while(1)
{
GPIO=0x00;
GPIO=0xff;
}
}
void interrupt isr_yy ( void )
{
RP0=1;
GPIF=0;
RP0=0;
GPIO=0xff;
while(1)
{
}
}

// ============================
我用 mplab sim 可進入 ISR .....
GP4 要不要加個 PULL LOW 電阻 ?

發表於: 2010/1/6 22:28
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 12F675使用GPIO變化中斷 HI-TECH C 9.65版
#4
資深會員
資深會員


查看用戶資訊
你好:
你下面這段程式是否有問題?
while(1)
{
GPIO=0x00;
GPIO=0xff;
}

Thanks.

發表於: 2010/1/6 12:10
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 12F675使用GPIO變化中斷 HI-TECH C 9.65版
#3
初級會員
初級會員


查看用戶資訊
TO BEEE&大家:

還是不行~~


我有將INTCON=0x88改為INTCON=0xC8

也有先將輸出CLEAR~~

所以程式改為

另外~~GP4我是用外部訊號觸發~~接到HIGH時才動作

因為我將GP4規畫為輸入

所以當有丟值時
GPIO=0x00;
GPIO=0xff;
這樣對他有影響??

另外~~
IOC <== 每次修改完程式第一次COMPILER後都會發生錯誤
第2次後就沒事~~是否有問題呢~~

還是有人又關於GPIO中斷的程式可以給我參考~~?


謝謝大家









#include <pic.h>


__CONFIG (INTIO & PROTECT & WDTDIS & MCLRDIS & CPD & BOREN & PWRTEN );

void interrupt isr_yy ( void );


void main( void )
{
RP0=1;
TRISIO=0x00;
RP0=0;
CMCON=0x07; //關閉比較器
GPIO=0; //CLEAR GPIO
RP0=1;
IOC=0x10;
ANSEL=0x00;
TRISIO=0x10;
OSCCAL=0x80; //111111XX~000000XX
INTCON=0xC8; //GPIE=1,GIE=1
RP0=0;
while(1)
{
GPIO=0x00;
GPIO=0xff;
}

}

void interrupt isr_yy ( void )
{
RP0=1;
GPIF=0;
RP0=0;
GPIO=0xff;
while(1)

{
}


}

發表於: 2010/1/6 12:08
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 12F675使用GPIO變化中斷 HI-TECH C 9.65版
#2
資深會員
資深會員


查看用戶資訊
INTCON.PEIE 也 置 1 試試看
GIE 最好 在最後面才 設 1
GP4 要先自己讀一次 ( BTFSS GPIO4 ) , 讓 MCU 確認其 設定
不要自己更改 其狀態 ( GPIO = 0 , GPIO = 0XFF )

發表於: 2010/1/6 10:46
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


12F675使用GPIO變化中斷 HI-TECH C 9.65版
#1
初級會員
初級會員


查看用戶資訊
各位好~~

小弟最近在試驗PIC 12F675 輸出端變化中斷

但一直"無法進入中斷程式"

能否幫我看一下程式哪邊有錯誤


程式解說~~

一開始~~輸出端GP5,GP2,GP1,GP0會送出類似方波的0101訊號

於GP4偵測到HIGH時(GP4有PULL DOWN)~~會進入中斷程式,<== GPIO變化中斷,是這樣用的嗎?

中斷程式 會將目前輸出端GP5,GP2,GP1,GP0維持HIGH

COMPILER HI-TECH C 9.65版

程式如下~~


#include <pic.h>


__CONFIG (INTIO & PROTECT & WDTDIS & MCLRDIS & CPD & BOREN & PWRTEN );

void interrupt isr_yy ( void );


void main( void )
{

RP0=0;
CMCON=0x07; //關閉比較器
GPIO=0; //CLEAR GPIO
RP0=1;
INTCON=0x88; //GPIE=1,GIE=1
IOC=0x10;
ANSEL=0x00;
TRISIO=0x10;
OSCCAL=0x80; //111111XX~000000XX
RP0=0;

while(1)
{
GPIO=0x00;
GPIO=0xff;
}

}

void interrupt isr_yy ( void )
{
RP0=1;
GPIF=0;
RP0=0;
GPIO=0xff;
while(1)
{
}


}

發表於: 2010/1/6 10:04
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... ]

教育訓練中心

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