⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 init_adc12.s

📁 dsPICDEM_v1_1开发板例程
💻 S
字号:
;START_HEADER
;
; dsPIC30F6014 Demo Source File
; (c) Copyright 2005 Microchip Technology, All rights reserved
;
; --------------------------------------------------------------------------
; File Revision History:
; --------------------------------------------------------------------------
;
; $Log: init_adc12.s,v $
; Revision 1.5  2005/09/06 07:16:29  C11300
; Changes for 30F6014A device
;
; Revision 1.4  2005/04/04 23:44:42  VasukiH
; Updates to comments in file header
;
; Revision 1.3  2005/04/04 23:16:17  VasukiH
; Updates for MPLAB C30 v1.30 compatiblity
;
; Revision 1.2  2003/11/04 02:36:12  VasukiH
; Changed A/D init for auto-scanning and auto-sampling
;
; Revision 1.1.1.1  2003/08/23 00:38:32  VasukiH
; First import of demo source into CVS Repository
;
;
;
; --------------------------------------------------------------------------
;
; Software and Development Tools Info:
; --------------------------------------------------------------------------
; Tool                          Version
; --------------------------------------------------------------------------
; MPLAB IDE                     7.0
; MPLAB C30 Toolsuite           1.30
; dsPICDEM(TM) Processor Board  1.10
; --------------------------------------------------------------------------
;
; File Notes:
; This file contains one A/D initialization routines
; 1.  _init_adc12
;
; 1. _init_adc12_A Description:
; (i)   This routine sets up the A/D for automatic sampling and conversion
;       for input waveform on pin AN3 at a sampling rate of 16000 Hz.
;       In this mode, the A/D module uses an internal counter to time sampling
;       and trigger conversion. An interupt is generated at the end of 16
;       conversions.
; (ii)  The input on pin AN3 is a Low-pass filtered (4KHz cutoff) output of
;       the MCP41010 8-bit Digital Potentiometer. This input is converted
;       using the Mux B selection on ADCHS so that 8 conversions from AN3
;       are provided per A/D interrupt. Frequency analysis is performed on
;       256 samples that are collected by the A/D converter on pin AN3/RB3.
; (iii) The Mux A selection in the A/D is set up for scanning four input channels:
;       - Potentiometer RP2 on pin AN4/RB4
;       - Potentiometer RP3 on pin AN5/RB5
;       - Potentiometer RP1 on pin AN6/RB6
;       - Temperature Sensor on pin AN8/RB8
;       These analog inputs are scanned using the MuxA input selector of the A/D.
;       In this mode, the A/D module automatically scans 4 input channels, i.e.,
;       the input channel to the module does not have to be changed in software.
; (iv)  The sequence of 16 conversions provides the following results in ADCBUF
;       through ADCBUFF:
;       AN4(ADCBUF0), AN3, AN5, AN3, AN6, AN3, AN8, AN3, AN4, AN3, AN5, AN3, AN6,
;       AN3, AN8, and AN3(ADCBUFF)
; (v)  One sample of each of the analog inputs RP1, RP2, RP3, Temp. Sensor are
;       converted and displayed on the LCD and via the UART to HyperTerminal.
;       RP1 also controls frequency of sine waves generated by the Digital Pot.
;       MCP41010.
;
;END_HEADER


.include "p30fxxxx.inc"

.global _init_adc12                     ;Provide global scope to routines

.section .text                          ;Code section in FLASH memory

_init_adc12:
        push    w0                      ;Save off w0 on to stack

        bclr    ADCON1, #ADON           ;Turn Off A/D


        mov     #0x03E4 ,w0             ;Set up automatic sampling and
                                        ;conversion.  Format conversion results
        mov     w0, ADCON1              ;to be read as 1.15(Q15) fractional data

        mov     #0x043D ,w0             ;Set up conversions per interrupt to 16
        mov     w0, ADCON2


        mov     #0x1A16 ,w0             ;Set up the Auto-sampling time and the
        mov     w0, ADCON3              ;Tad time to yield 8000 samples/second
                                                                                ;on AN3


        mov     #0x0300 ,w0             ;Set up the analog channel to convert
        mov     w0, ADCHS               ;on pin AN3/RB3


        mov     #0xFE87 ,w0             ;Set up AN3/RB3 as an analog pin
        mov     w0, ADPCFG              ;and the rest as digital


        mov     #0x0170 ,w0             ;Disable channel scanning
        mov     w0, ADCSSL


        bclr    IFS0, #ADIF             ;Clear A/D interrupt flag and
        bset    IEC0, #ADIE             ;enable A/D ISR processing

        mov.b   #0b11100000, w0         ;Set up A/D interrupt priority
        ior.b   IPC2H                   ;to 7!!

        pop     w0                      ;Restore w0

        return                          ;Return to calling routine


.end                                    ;EOF


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -