• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: PIC18F4431 AD轉換
#3
高級會員
高級會員


查看用戶資訊
謝謝版主回應

發表於: 2006/5/9 17:37
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC18F4431 AD轉換
#2
版主
版主


查看用戶資訊
;******************************************************************************
;   
This file is a basic template for assembly code for a PIC18F4331Copy    *
;   
this file into your project directory and modify or add to it as needed.  *
;                                                                             *
;   
The PIC18FXXXX architecture allows two interrupt configurationsThis     *
;   
template code is written for priority interrupt levels and the IPEN bit   *
;   
in the RCON register must be set to enable priority levels. If IPEN is    *
;   
left in its default zero stateonly the interrupt vector at 0x008 will   *
;   
be used and the WREG_TEMPBSR_TEMP and STATUS_TEMP variables will not    *
;   
be needed.                                                                *
;                                                                             *
;   
Refer to the MPASM User's Guide for additional information on the         *
;   features of the assembler.                                                *
;                                                                             *
;   Refer to the PIC18F2331/2431/4331/4431 Data Sheet for additional          *
;   information on the architecture and instruction set.                      *
;                                                                             *
;******************************************************************************
;                                                                             *
;    Filename:                                                                *
;    Date:                                                                    *
;    File Version:                                                            *
;                                                                             *
;    Author:                                                                  *
;    Company:                                                                 *
;                                                                             * 
;******************************************************************************
;                                                                             *
;    Files required:         P18F4331.INC                                     *
;                                                                             *
;******************************************************************************

    LIST P=18F4331        ;directive to define processor
    #include <P18F4331.INC>    ;processor specific variable definitions

;******************************************************************************
;Configuration bits
;Microchip has changed the format for defining the configuration bits, please 
;see the .inc file for futher details on notation.  Below are a few examples.



;   Oscillator Selection:
;    CONFIG    OSC = LP             ;LP

;******************************************************************************
;Variable definitions
; These variables are only needed if low priority interrupts are used. 
; More variables may be needed to store other special function registers used
; in the interrupt routines.

        CBLOCK    0x080
        WREG_TEMP    ;variable used for context saving 
        STATUS_TEMP    ;variable used for context saving
        BSR_TEMP    ;variable used for context saving
        ENDC

        CBLOCK    0x000
        EXAMPLE        ;example of a variable in access RAM
        ENDC

;******************************************************************************
;EEPROM data
; Data to be programmed into the Data EEPROM is defined here

        ORG    0xf00000

        DE    "Test Data",0,1,2,3,4,5

;******************************************************************************
;Reset vector
; This code will start executing when a reset occurs.

        ORG    0x0000

        goto    Main        ;go to start of main code

;******************************************************************************
;High priority interrupt vector
; This code will start executing when a high priority interrupt occurs or
; when any interrupt occurs if interrupt priorities are not enabled.

        ORG    0x0008

        bra    HighInt        ;go to high priority interrupt routine

;******************************************************************************
;Low priority interrupt vector and routine
; This code will start executing when a low priority interrupt occurs.
; This code can be removed if low priority interrupts are not used.

        ORG    0x0018

        movff    STATUS,STATUS_TEMP    ;save STATUS register
        movff    WREG,WREG_TEMP        ;save working register
        movff    BSR,BSR_TEMP            ;save BSR register

;    *** low priority interrupt code goes here ***


        movff    BSR_TEMP,BSR            ;restore BSR register
        movff    WREG_TEMP,WREG        ;restore working register
        movff    STATUS_TEMP,STATUS    ;restore STATUS register
        retfie

;******************************************************************************
;High priority interrupt routine
; The high priority interrupt code is placed here to avoid conflicting with
; the low priority interrupt vector.

HighInt:

;    *** high priority interrupt code goes here ***


        retfie    FAST

;******************************************************************************
;Start of main program
; The main program code is placed here.

Main:

;    *** main code goes here ***

; Program ADC as single-hhot mode , One channel @ RA0  ,
        movlw        B'
00000000'
        movwf        ADCON0
        movlw        B'
00000000'
        movwf        ADCON1
        movlw        B'
00011101'        ; TAD = Fosc/16 , TACQ = 6TAD
        movwf        ADCON2 
         movlw        B'
00000000'        ; Interrupt is generated when each word is written to the buffer , All triggers disabled 
        movwf        ADCON3
        movlw        B'
00000000'
        movwf        ADCHS            ; Group-A = AN0 , Group-B = AN1 , Group-C = AN2 , Group-C = AN3
        movlw        B'
11111110'        
        movwf        ANSEL0            ; Only AN0 is Analog input 
        movlw        B'
00000001'        ;
        movwf        ANSEL1

        clrf            TRISD

        bsf            ADCON0,0            ; Turn AD ON bit

ADC_Loop:
        bsf            ADCON0,GO
Wait_ADC
        btfsc        ADCON0,GO
        goto        Wait_ADC

        movff        ADRESH,LATD
        nop
        bra            ADC_Loop 


;******************************************************************************
;End of program

        END

發表於: 2006/5/8 18:14
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


PIC18F4431 AD轉換
#1
高級會員
高級會員


查看用戶資訊
請問各位前輩有18F4431的AD轉換是範例程式可以參考嗎

發表於: 2006/5/5 18:10
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... ]

教育訓練中心

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