Re: 有關16F913的ADC程式碼問題
|
||||
---|---|---|---|---|
新會員
|
謝謝>"<
因為是第一次使用C語言寫 跟平時有所差異 其實有點小傷腦經 感謝大大給我方向 讓我知道哪裡還有我所需知道的工具
發表於: 2008/1/4 19:19
|
|||
|
Re: 有關16F913的ADC程式碼問題
|
||||
---|---|---|---|---|
中級會員
|
如果你是用Hi-Tech PICC,要寫成GODONE = 1而不是GO/DOWN = 1…
發表於: 2008/1/4 9:48
|
|||
|
有關16F913的ADC程式碼問題
|
||||
---|---|---|---|---|
新會員
|
#include <pic.h>
__CONFIG (UNPROTECT & DEBUGEN & MCLRDIS & BOREN & PWRTEN & INTIO & WDTDIS & IESODIS & FCMDIS);// #define ClearScreen PutStr("\x1B[2J"); void InitPIC16F913(void); void PutStr(const char *data); main() { InitPIC16F913(); ClearScreen while(1) { unsigned char tempres0; GO/DOWN = 1; while(GO/DOWN); tempres0 = ADRESH; while(!(TXSTA & 0x02)); TXREG = tempres0;//傳出的暫存 tempres0 = ADRESL; while(!(TXSTA & 0x02)); TXREG = tempres0;//傳出的暫存 } void InitPIC16F913(void) { OPTION = 0x07; OSCCON=0b01100101; OSCTUNE=0b00000000; TRISA = 0b00000000; TRISC = 0b10000000; TXSTA = 0b00100100; RCSTA = 0b10010000; SPBRG = 25; PIE1=0b00100000; INTCON=0b11000000; ADCON1 = 0b00000000; //All A/D port as Analog input //Init USART: 9600,8bit,asynchronous ADCON0 = 0b10000001; } void PutStr(const char *data) { do { while(!(TXSTA & 0x02)); TXREG = *data; } while( *data++ ); }; 以上是我參考組合語言跟一些程式所改寫的程式 可是不知道哪裡出錯 GO/DOWN = 1; ↑這一行一直出錯,他不是意思是說可以直接設置其標才開始進行轉換,但是他卻不讓我設置。 請問我是哪裡出錯
發表於: 2008/1/3 19:09
|
|||
|