• 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: 有關16F913的ADC程式碼問題
#4
新會員
新會員


查看用戶資訊
謝謝>"<
因為是第一次使用C語言寫
跟平時有所差異 其實有點小傷腦經
感謝大大給我方向
讓我知道哪裡還有我所需知道的工具

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


Re: 有關16F913的ADC程式碼問題
#3
版主
版主


查看用戶資訊
要參考一下 C:\HT-PIC\include\pic16f91x.h 檔裡的說明,有些暫存器位元的定義會跟 Data Sheet 的定義自不一樣。 
/* Definitions for ADCON0 register */
static                bit    ADON        @ ((unsigned)&ADCON0*8)+0;
static 
volatile       bit    GODONE        @ ((unsigned)&ADCON0*8)+1;
static                
bit    CHS0        @ ((unsigned)&ADCON0*8)+2;
static                
bit    CHS1        @ ((unsigned)&ADCON0*8)+3;
static                
bit    CHS2        @ ((unsigned)&ADCON0*8)+4;
static                
bit    VCFG0        @ ((unsigned)&ADCON0*8)+5;
static                
bit    VCFG1        @ ((unsigned)&ADCON0*8)+6;
static                
bit    ADFM        @ ((unsigned)&ADCON0*8)+7;

這是在 Hi-Tech PICC 裡所定義的 ADC 的位元名稱 (PIC16F913)

發表於: 2008/1/4 10:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 有關16F913的ADC程式碼問題
#2
中級會員
中級會員


查看用戶資訊
如果你是用Hi-Tech PICC,要寫成GODONE = 1而不是GO/DOWN = 1…

發表於: 2008/1/4 9:48
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


有關16F913的ADC程式碼問題
#1
新會員
新會員


查看用戶資訊
#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
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... ]

教育訓練中心

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