Analog Input
- A/D Conversion Experiment
I. Purpose
Through A/D conversion, the voltage value of the external analog input channel can be correctly read.
II. Experimental procedures and parameter settings
1> The connector option settings and startup code are the same as the previous experiment
2> C language code
#i nclude "AT91SAM7S64.h"
#i nclude "Board.h"
volatile unsigned int EXT_AD_Val[4]; //Define A/D conversion result value
int main(void)
{unsigned char i;
*AT91C_ADC_CR = AT91C_CKGR_MOSCEN; //Software reset of ADC, that is, clear all registers of ADC
*AT91C_PMC_SCER = AT91C_CKGR_MOSCEN; //Enable the processor clock of the system clock register
*AT91C_PMC_PCER = 1 91C_ID_ADC; //Enable ADC clock
*AT91C_PIOA_PDR = EXT_AD0 | EXT_AD1; //Disable the I/O port function of the pin and use it as analog input function
*AT91C_ADC_MR = 0x0f1f3f00; //Software start, 10-bit resolution, 128 division
*AT91C_ADC_CHER = 0x33; //Enable channels 0, 1, 4, 5
*AT91C_ADC_CHDR = 0xcc; //Disable channels 2, 3, 6, 7
*AT91C_ADC_IDR = 0xfffff; //Disable all ADC interrupts
while (1)
{ *AT91C_ADC_CR = 0x2; //Start conversion
while (1)
{ if ((*AT91C_ADC_SR) & 0x33) //Wait for conversion to end
{ EXT_AD_Val[0] = (*AT91C_ADC_CDR0) & 0x3ff; //Read 10-bit result value
EXT_AD_Val[1] = (*AT91C_ADC_CDR1) & 0x3ff;
EXT_AD_Val[2] = (*AT91C_ADC_CDR4) & 0x3ff;
EXT_AD_Val[3] = (*AT91C_ADC_CDR5) & 0x3ff;
for (i = 0; i
break;
}
}
}
}
3. Summary
Executing software reset of ADC will clear all ADC related registers, so it must be executed before setting ADC related registers.
Keywords:ARM
Reference address:ARM Getting Started Notes (5)
- A/D Conversion Experiment
I. Purpose
Through A/D conversion, the voltage value of the external analog input channel can be correctly read.
II. Experimental procedures and parameter settings
1> The connector option settings and startup code are the same as the previous experiment
2> C language code
#i nclude "AT91SAM7S64.h"
#i nclude "Board.h"
volatile unsigned int EXT_AD_Val[4]; //Define A/D conversion result value
int main(void)
{unsigned char i;
*AT91C_ADC_CR = AT91C_CKGR_MOSCEN; //Software reset of ADC, that is, clear all registers of ADC
*AT91C_PMC_SCER = AT91C_CKGR_MOSCEN; //Enable the processor clock of the system clock register
*AT91C_PMC_PCER = 1 91C_ID_ADC; //Enable ADC clock
*AT91C_PIOA_PDR = EXT_AD0 | EXT_AD1; //Disable the I/O port function of the pin and use it as analog input function
*AT91C_ADC_MR = 0x0f1f3f00; //Software start, 10-bit resolution, 128 division
*AT91C_ADC_CHER = 0x33; //Enable channels 0, 1, 4, 5
*AT91C_ADC_CHDR = 0xcc; //Disable channels 2, 3, 6, 7
*AT91C_ADC_IDR = 0xfffff; //Disable all ADC interrupts
while (1)
{ *AT91C_ADC_CR = 0x2; //Start conversion
while (1)
{ if ((*AT91C_ADC_SR) & 0x33) //Wait for conversion to end
{ EXT_AD_Val[0] = (*AT91C_ADC_CDR0) & 0x3ff; //Read 10-bit result value
EXT_AD_Val[1] = (*AT91C_ADC_CDR1) & 0x3ff;
EXT_AD_Val[2] = (*AT91C_ADC_CDR4) & 0x3ff;
EXT_AD_Val[3] = (*AT91C_ADC_CDR5) & 0x3ff;
for (i = 0; i
break;
}
}
}
}
3. Summary
Executing software reset of ADC will clear all ADC related registers, so it must be executed before setting ADC related registers.
Previous article:ARM Getting Started Notes (6)
Next article:ARM Getting Started Notes (4)
Recommended ReadingLatest update time:2024-11-16 23:42
Interpretation of ARM2440ddr.h file
After the board is powered on, it will start executing from here, mainly completing basic initialization, judging whether to start from NOR or NAND, and then moving the program to SDRAM. After the transfer is successful, it will jump to the main function for execution.
Let's start looking at its specific code no
[Microcontroller]
A design scheme of speaker-independent speech recognition system based on ARM processor
0 Introduction
With the widespread application of high-tech in the military field, weapons and equipment are gradually developing towards high, precise and advanced directions. Traditional military training often fails to achieve the expected training effect due to long training time, high training costs and nar
[Microcontroller]
ARM7 2131 BEEP Program Analysis
ARM7 BEEP Program Analysis
In the schematic diagram, we can see that the buzzer is connected to the P07 port, and the interface is short-circuited.
#include "config.h"
#define BEEP 1 7 // P0.7 controls the buzzer, low-level buzzer
Includes a config.h header file, which mainly defines the data type, clock fr
[Microcontroller]
Wireless data transceiver system based on ARM and nRF905
The designed wireless data transceiver system is an important part of the wireless follow-up control system. It is mainly composed of nRF905 wireless transceiver module and LPC2148 ARM development board. It is used to realize wireless data transmission between the manual system and the follow-up system, effectively
[Microcontroller]
ARM chip development learning (S5PV210) - icache, dcache introduction and how to turn on and off icache
What are icache and dcache? Cache is a high-speed cache memory, icache (instructions cache) is an instruction cache memory, and dcache (data cache) is a data cache memory. The basic rule of storage media is that the faster the read and write speed, the higher the price per unit storage capacity. In order to balance th
[Microcontroller]
Robot arm control system based on ARM core processor
In recent years, with the development of MEMS and related technologies, the field of micro-robotics has attracted more and more attention. However, due to the small size of the parts, the assembly of micro-robot components requires very high precision, and general assembly methods cannot meet the requirements. This
[Industrial Control]
Application of ARM core board in dynamic urine volume monitor
1.1 Project Introduction
Urine volume monitoring is an important part of detecting multiple indicators of patients. It is the most direct and sensitive physiological indicator reflecting the level of renal blood perfusion. For critically ill patients, urine volume can often indicate renal function disorders bef
[Medical Electronics]
Introduction to ARM development software and practical tools
Introduction to arm development software and practical tools 1. Introduction to compiler 1. ADS1.2 ADS is ARM's integrated development environment software, and its functions are very powerful. Its predecessor is SDT, which is the development environment software of arm company a few years ago. At present, SD
[Microcontroller]
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Doherty Amplifier
- EEWORLD University----[High Precision Laboratory] Motor Drive: Stepper Motor Driver
- 2812 TxPR register write failure caused by TxCON highest bit
- [GD32L233C-START Evaluation] Development Environment Construction
- Disadvantages of Traditional Differential Amplifiers and Solutions
- Can I ask how the air pressure sensor can achieve accurate height (altitude) measurement and ignore the influence of wind speed?
- The Differences and Relationships between POP3, SMTP and IMAP
- [Evaluation of SGP40] + IoT remote monitoring application development - device-side development
- TPS61221 power chip management
- Showing Products (4) - Atmel Development Board