The 32-bit microcontrollers I have come into contact with: STM32, LM3S all have library functions. Using library functions can speed up the project progress, and there is no need to check the registers at the bottom level, etc. The library function location of PIC32 is:
D:\Program Files\Microchip\MPLAB C32\pic32-libs\peripheral
If you install it on the C drive, just change the path. We can see that all the peripherals are packaged. There is a library function manual on the Internet. I can't download it due to poor network, so I will send the address to you:
http://hades.mech.northwestern.edu/images/5/5e/32-bit-Peripheral-Library-Guide.pdf
Next, we will teach you how to use the library function to make the interrupt button trigger the LED to turn on and off.
From the connection of the button, we can see that it does not have the function of input level CN. Fortunately, all the pins are brought out on the development board. We choose port 1 at the JB slot, which is PG9/CN11, as shown in the figure. Of course, other ports are also fine as long as they have the function of input level CN.
The programming steps are:
// Step 1: STEP 1. Configure the port direction
PORTSetPinsDigitalOut(IOPORT_B,BIT_10);//LED1
mPORTBClearBits(BIT_10);//LED1=0
PORTSetPinsDigitalIn(IOPORT_G, BIT_9); //PG9 set input
//Step 2: Set pin pull-up
mCNOpen(CONFIG, PINS, PULLUPS);
temp = mPORTGRead(); //Read to eliminate external influences
//Step 3: Configure interrupts, enable interrupts, and set priorities
ConfigIntCN(INTERRUPT);
//Finally open the interrupt table
INTEnableSystemMultiVectoredInt();
Previous article:Wulin teaches you how to configure the PIC32 (IV) clock
Next article:Wulin teaches you how to use PIC32 (Part 2) Key control
Recommended ReadingLatest update time:2024-11-16 13:46
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- 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
- LSM6DSL cannot generate interrupts, WAKE_UP_SRC is always 0; changing CTRL1_XL doubles the Z-axis reading
- MSP432 learning experience: system tick timer
- Introduce the factors to be considered in selecting DSP chips with examples
- Tektronix Industrial Application Standard and High-Speed Interface Test Solutions
- Ora Good Cat “chip replacement incident”: How big is the gap between the two chips?
- 【NUCLEO-L552ZE Review】+ Bluetooth communication experiment (1)
- Sigma-Delta ADC Digital Filter Types
- Remote upgrade of HuaDa MCU HC32L110
- Explanation of the stack pointer register SP of msp430
- Qorvo at CES 2020: Innovative Solutions for 5G, IoT, Wi-Fi 6 and V2X