• 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: ADC轉換
#5
新會員
新會員


查看用戶資訊
大大們 超級感謝你們地,謝天謝地終於正常了,很愛你們優^^..呵呵

發表於: 2009/6/16 0:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換
#4
資深會員
資深會員


查看用戶資訊
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
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換
#3
新會員
新會員


查看用戶資訊
大大們
很感謝妳替小弟解答,可是小弟用示波器看了一下,調一下10K的VR,結果好像都在不同的同樣幾個頻率下跳阿跳,難道是AD的初始值設錯,以致丟出的ADRESH值都一樣嗎??

發表於: 2009/6/15 23:03
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: ADC轉換
#2
資深會員
資深會員


查看用戶資訊
參照:

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 ; ----XXXXXXX ( 載入 ADRESH 的 ADDRESS )
MOVF ADRESH , W ; ----OOOOOOO( 載入 ADRESH 的 值 )
movwf ADStatus
return
;----------------------------------------------------
Watch:
movlw D'8'
movwf scaler
Watchloop:
rlf ADStatus,F ; ------------
; movwf ADStatus
; bcf STATUS,RP0
BCF GPIO , GP5 ; ---------
btfsc STATUS,C
bsf GPIO,GP5
; btfss STATUS,C
; bcf GPIO,GP5
call Delay250ms
decfsz scaler , F
goto Watchloop

BSF scaler , 3
BCF GPIO , GP5
WATCH_REST: ; 休息 2 秒 , 再看下一個變化 , 試試看用 VR
CALL Delay250ms
DECFSZ scaler , F
GOTO WATCH_REST
return
;-----------------------------------------------------
Delay1ms:
movlw .198
movwf Delay1
; nop
; nop
GOTO $ + 1 ; 跳下一個 指令( 2 指令周期 )
Delay1ms_01:
; nop
; nop
GOTO $ + 1 ; 跳下一個 指令 ( 2 指令周期 )
decfsz Delay1, F
goto Delay1ms_01
RETURN
;---------------------------------------------------------
Delay250ms:
movlw .250
movwf Delay2
Delay250ms_01:
call Delay1ms
;CLRWDT
decfsz Delay2, F
goto Delay250ms_01
RETURN

end

發表於: 2009/6/15 14:20
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


ADC轉換
#1
新會員
新會員


查看用戶資訊
妳好
我初碰這單晶片,目前在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
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... ]

教育訓練中心

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