PIC16F873 A/D conversion program

Publisher:心灵之窗Latest update time:2016-08-26 Source: eefocusKeywords:PIC16F873 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
PIC16F873 A/D conversion program

;The A/D test program for PIC16F873 implements the following functions:
;(1) Use RA0/AN0 as the A/D conversion input channel;
;(2) The reference voltage source VREF selects the internal VDD and VSS;
;(3) The A/D conversion clock source selects a 4MHz oscillator;
;(4) Eight-bit data accuracy, and the AD result is written to port C.

;8L8ADSY.ASM A/D conversion
list p=16f873
INCLUDE "P16F873.INC"

       ORG 0x000
MAIN
       NOP
       BANKSEL ADCON1 ;Select RAM data memory bank 1, equivalent to BSF STATUS, RP0
       MOVLW B'00000000' ;Select RA5/AN4 as analog input, the result format is left-aligned
       MOVWF ADCON1 ;Select internal VDD and VSS for reference voltage source VREF
       CLRF TRISC ;Set port C as output
       BANKSEL ADCON0 ;Select RAM data memory bank 0, equivalent to BCF STATUS, RP0
       MOVLW B'01100001' ;Set clock source 8Tosc, enable ADC, AN0 channel is selected
       MOVWF ADCON0
       CLRF PORTC ;Clear port C

AtoD
       NOP; In order to ensure the sampling time, usually,
       a NOP of more than 20us should be inserted; Time delay or arrange a considerable length of application.
       BSF ADCON0,GO; GO position 1, start A/D conversion
ADWAIT
       BTFSC ADCON0,GO; After the A/D conversion is completed, the GO bit will be cleared to 0
       GOTO ADWAIT; If the conversion is not completed, return to continue testing
       MOVF ADRESH,W; If the conversion is completed, read the A/D result into W
       MOVWF PORTC; Write the AD result to port C
       GOTO AtoD; Cycle A/D conversion
       END

Keywords:PIC16F873 Reference address:PIC16F873 A/D conversion program

Previous article:PIC microcontroller commonly used 1s delay subroutine
Next article:AD conversion assembly program example

Recommended ReadingLatest update time:2024-11-16 13:26

Traffic Solution | Building a smart public transportation system based on the Flink A40i core board
Waiting for the bus is an annoying thing. This process will constantly challenge our patience. Maybe your hard work will only result in the bus passing by you, or maybe your patient waiting will only result in the bus being late. Even if you wait for the bus, you still have to take the risk of not being able to get
[Embedded]
Traffic Solution | Building a smart public transportation system based on the Flink A40i core board
Using W7100A for Network Power Management
Network power management  application background:  With the development of information technology, the scale of data centers is also expanding. With more investment and more equipment is no longer a new thing for modern data centers to cover the entire floor, occupy different buildings in the same city, and even distr
[Microcontroller]
Using W7100A for Network Power Management
Apple will release Apple TV 6 with A12X: debuting on the same stage as iPhone 12
       According to the latest report from foreign media, Apple's upcoming wave of new products also includes Apple TV 6. This should be the cheapest device in the Apple family equipped with A12X. It is expected to debut on the same stage as the iPhone 12.   The report mentioned that Apple is developing a new version
[Mobile phone portable]
Apple's A14 and A15 Bionic, Apple's game-changing SoC solutions
Lyon, France - December 16, 2021 | "Apple's A14 Bionic, fully dedicated to the iPhone 12 series and iPad, came out in 2020 at the right time," said Ying-Wu Liu, technology and cost analyst at System Plus Consulting. "Apple's A15 Bionic followed closely behind, offering multiple advantages for the iPhone 13 and iPad
[Mobile phone portable]
The Loongson 3A6000 computer is officially announced to be released within the year and plans to develop a pure large-core 8-core desktop CPU.
According to news on September 11, Loongson Zhongke recently responded to questions on the investor Q&A platform and revealed some launch planning information for new processors. The first is the Loongson 3A6000 processor that everyone is most concerned about. Loongson Zhongke will hold a press conference in the fourt
[Embedded]
The Loongson 3A6000 computer is officially announced to be released within the year and plans to develop a pure large-core 8-core desktop CPU.
DPU company Yisixin Technology announced the completion of Pre-A round of financing
Recently, Yisixin Technology (Shanghai) Co., Ltd. (hereinafter referred to as Yisixin Technology) announced the completion of its Pre-A round of financing. This round of financing was jointly led by Lenovo Capital and Oak Bud Capital, and followed by Lishi Ventures, Dingxin Capital, Oriental Fortune Capital, and Yiqi
[Mobile phone portable]
OK6410A Development Board (VIII) 49 linux-5.11 OK6410A Linux user space virtual memory management VMA
I have previously introduced five ways to manage Linux virtual memory. One of them (called VMA) is used to manage user space virtual memory. This article will introduce VMA. What is VMA mmap(VMA) in mm_struct in task_struct // The structure type of mmap is vm_area_struct It can be seen that VMA is a data structure,
[Microcontroller]
NS LMZ14203H input 42V output 3A power supply solution
NS's LMZ14203H is a 3A SIMPLE SWITCHER power module with a maximum input voltage of 42V. It has excellent power conversion efficiency, line and load regulation, and output accuracy. The input voltage is 6V-42V, the output voltage is as low as 5V, and the efficiency is as high as 97%. It is mainly used in markets inc
[Power Management]
NS LMZ14203H input 42V output 3A power supply solution
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号