Re: ADC轉換
|
||||
---|---|---|---|---|
新會員
|
大大們 超級感謝你們地,謝天謝地終於正常了,很愛你們優^^..呵呵
發表於: 2009/6/16 0:03
|
|||
|
Re: ADC轉換
|
||||
---|---|---|---|---|
資深會員
|
ADconverter:
bcf STATUS,RP0 bsf ADCON0,GO call Delay250ms call Delay250ms Wait: btfsc ADCON0,GO goto Wait ;btfsc ADCON0,GO-->這行多餘的吧...
發表於: 2009/6/15 23:36
|
|||
|
Re: ADC轉換
|
||||
---|---|---|---|---|
新會員
|
大大們
很感謝妳替小弟解答,可是小弟用示波器看了一下,調一下10K的VR,結果好像都在不同的同樣幾個頻率下跳阿跳,難道是AD的初始值設錯,以致丟出的ADRESH值都一樣嗎??
發表於: 2009/6/15 23:03
|
|||
|
ADC轉換
|
||||
---|---|---|---|---|
新會員
|
妳好
我初碰這單晶片,目前在ADC轉換這遇上問題,由於想知道再AD轉換時暫存器的動作,所以寫了這個code,結果GP5燈號一直閃著同樣的頻率,無法根據這個(5V接1K電阻在接10K電阻在10K前拉信號到AN0)輸入,得到好的輸出,怪怪的???可以麻煩大大先進們幫幫小弟嗎? list p=12f675 include <P12f675.INC> __CONFIG _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _BODEN_OFF ADStatus EQU 0x20 W_temp EQU 0x21 STATUS_Temp EQU 0x22 scaler EQU 0x27 Delay1 EQU 0x23 Delay2 EQU 0x24 Delay3 EQU 0x25 ADStatus1 EQU 0x26 ;***********Resect Vector*************** org 0x00 nop goto MainLine ;********** Main Program *************** MainLine call Initial MainLoop call ADconverter call Watch goto MainLoop ;*********Initial Subroutine************ Initial bsf STATUS,RP0 movlw B'00000001' movwf TRISIO bcf STATUS,RP0 movlw 07h movwf CMCON bsf STATUS,RP0 clrf ADRESL movlw B'00010001' movwf ANSEL bcf STATUS,RP0 clrf ADCON0 movlw B'0000001' movwf ADCON0 clrf ADRESH return ;************A/D converter************** ADconverter bcf STATUS,RP0 bsf ADCON0,GO call Delay250ms call Delay250ms Wait btfsc ADCON0,GO goto Wait btfsc ADCON0,GO movlw ADRESH movwf ADStatus return ;------------------------------------------------------------------------------ Watch movlw D'8' movwf scaler Watchloop rlf ADStatus,W movwf ADStatus bcf STATUS,RP0 btfsc STATUS,C bsf GPIO,GP5 btfss STATUS,C bcf GPIO,GP5 call Delay250ms decfsz scaler goto Watchloop return ;------------------------------------------------------------------------------ Delay1ms: movlw .198 movwf Delay1 nop nop Delay1ms_01: nop nop decfsz Delay1, F goto Delay1ms_01 retlw 0x00 ;------------------------------------------------------------------------------ Delay250ms: movlw .250 movwf Delay2 Delay250ms_01: call Delay1ms ;CLRWDT decfsz Delay2, F goto Delay250ms_01 retlw 0x00 end
發表於: 2009/6/14 23:51
|
|||
|