Re: 關於F877A的AD中斷問題...
|
||||
---|---|---|---|---|
新會員
|
真的很感謝你的詳細解說
講的很詳細 幫了我好大的忙 也建立了我ㄧ些觀念 謝謝你~
發表於: 2008/3/14 22:21
|
|||
|
關於F877A的AD中斷問題...
|
||||
---|---|---|---|---|
新會員
|
想請教一下為什麼下面這個程式
我原先是沒有寫中斷 有成功\r 成功結果會是PORTD的0~3位元輪流亮滅 (EX: 暗的順序是:0.1.2.3.3.2.1.0.0.1.2.3....) 但是我只是把放在主程式的轉換AD寫到中斷裏 (就是判斷ADIF有沒有變為1) 就不能跑 想請問程式哪里出了問題? (RA0輸入 一個sin弦波 把AD轉換結果輸出到PORTD讓LED燈閃: #include <pic.h> __CONFIG(HS&WDTDIS&PWRTDIS&BORDIS&LVPDIS&DEBUGEN&PROTECT); void init_a2d(void){ ADCON0=0b01000000; ADCON1=0; ADON=1; } unsigned char read_a2d(unsigned char channel){ channel&=0x07; ADCON0&=0xC5; ADCON0|=(channel<<3); ADGO=1; while(ADGO)continue; return(ADRESH); } void main(void){ init_a2d(); GIE=1; PEIE=1; ADIE=1; TRISD=0xF0; while(1) {;} } void interrupt usart(void) { unsigned char x; x=read_a2d(1); PORTD = (8>>(x>>6)); ADIF=0; } 先謝謝各位了~
發表於: 2008/3/12 20:46
|
|||
|