//ADC12 single channel single interrupt mode
#include
unsigned ADC_Result;
void ADC12_Init();
void main(){
WDTCTL = WDTPW + WDTHOLD;
ADC12_Init();
_BIS_SR(GIE);
ADC12CTL0 |= ADC12SC;
while(1);
}
//
void ADC12_Init(){
ADC12CTL0 &= ENC;
P6DIR &= ~BIT6;
P6SEL |= BIT6; //Select the second function of P6.6
ADC12CTL0 = ADC12ON + SHT0_6 + REFON; //Turn on ADC12, you can convert, sample and hold timer 0, usually select 6, 8, turn on the internal reference voltage generator
ADC12CTL0 &= ~REF2_5V; //Select the internal reference voltage as 1.5V, select
ADC12CTL1 = SHP + CONSEQ_0 + SHS_0; //Use sampling timer + single channel single conversion mode + sampling input signal source control bit (ADC12SC,).
ADC12MCTL0 = SREF_1 + INCH_6; //Reference voltage Vref+,AVss.Channel 6
ADC12IE |= BIT0; //Interrupt enable
ADC12CTL0 |= ENC; // + ADC12SC; //Conversion enable
}
#pragma vector=ADC_VECTOR
__interrupt void ADC12ISR(){
ADC_Result = ADC12MEM0; //Here you can observe the value from IAR
ADC12CTL0 |= ADC12SC;
}
Previous article:Some commonly used C language control programs for msp430 --- ADC12 (3)
Next article:Some commonly used C language control programs for msp430 --- ADC12 (1)
Recommended ReadingLatest update time:2024-11-15 09:07
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Detailed explanation of intelligent car body perception system
- How to solve the problem that the servo drive is not enabled
- Why does the servo drive not power on?
- What point should I connect to when the servo is turned on?
- How to turn on the internal enable of Panasonic servo drive?
- What is the rigidity setting of Panasonic servo drive?
- How to change the inertia ratio of Panasonic servo drive
- What is the inertia ratio of the servo motor?
- Is it better for the motor to have a large or small moment of inertia?
- What is the difference between low inertia and high inertia of servo motors?
- Looking for Mentor Graphics WG2004
- millimeter wave, millimeter wave radar, millimeter wave sensor, 5G and millimeter wave,
- PMOS is used as solid-state relay, high-side bidirectional switch, anti-current backflow, anti-reverse connection circuit
- MSP430F5529 LAB CODE experimental routine
- Compile and debug ESP32 programs in VSCode
- Questions about generating light painting with allegro16.6
- NUCLEO-G431RB Review -> OPAMP
- CCS8.0
- Advantages of Integrated Current Sensing
- [GD32L233C-START Review] - 8. Driving a 1.5-inch OLED screen using ordinary GPIO