AD conversion assembly program example

Publisher:qin199099Latest update time:2016-08-26 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
AD conversion program example

;This program is a simple AD conversion demonstration program, which performs 0-5V voltage test
;The conversion result is output from port C and is very intuitive 
;The converted value ADRESH is 0 at 0V, and the LEDs are all off, and all light up at 5V 
;================================================

include

ORG 0X00
NOP
START 
BCF STATUS,RP0
CLRF PORTC
MOVLW B'01000001' ;D7 D6=01 AD conversion clock frequency = FOSC/8
MOVWF ADCON0 ;D5 D4 D3=000 AD conversion analog channel selection RA0/AN0
                         ;D2=0 AD completed or not in progress D0=0 turn off ADC
BSF STATUS,RP0 
MOVLW B'10000111' ;D7=1 cancel pull-up, D6=0 INT falling edge trigger,
MOVWF OPTION_REG ;D5=0 TOCK1 uses internal clock D4=0 TOCK1 rising edge increment
                    ; D3=0 for TMR0 D2 D1 D0=1 TMR0 1:256 division
CLRF TRISC
MOVLW B'00001110' ;D3 D2 D1 D0 1110 selects RA0 as the analog port.
MOVWF ADCON1; D7=0 left-aligned The lower six bits of ADRESL are read as 0
BCF STATUS, RP0


MAIN
BTFSS INTCON,T0IF ; Wait for TMR0 timer overflow interrupt
GOTO MAIN 
BCF INTCON,T0IF ; Clear TMR0 timer overflow flag
BSF ADCON0,GO ; Turn on A/D


WAIT
BTFSS PIR1,ADIF ; Wait for A/D to complete
GOTO WAIT
MOVF ADRES,W ; A/D value is output from PORTC
MOVWF PORTC
GOTO MAIN
END

Reference address:AD conversion assembly program example

Previous article:PIC16F873 A/D conversion program
Next article:PIC microcontroller A/D conversion process

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号