Wulin teaches you to learn PIC32 (Part 3) Teach you to use library functions to write interrupt buttons

Publisher:素心悠远Latest update time:2017-02-17 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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();


Reference address:Wulin teaches you to learn PIC32 (Part 3) Teach you to use library functions to write interrupt buttons

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

32-bit MCU Knowledge Explanation: Microchip PIC32 Series (IV)
UART Configuration   The UART uses the standard Non-Return-to-Zero (NRZ) format (1 start bit, 8 or 9 data bits, and 1 or 2 stop bits). Parity is provided by hardware and can be configured by the user as even, odd, or no parity. The most common data format is 8 bits, no parity, and 1 stop bit (represented by 8, N,
[Analog Electronics]
32-bit MCU Knowledge Explanation: Microchip PIC32 Series (IV)
PIC32 interrupt and oscillator configuration
A month has passed since the summer vacation. I am enjoying the sweat and passion in the busy cornfield. However, I still haven't fallen behind in my studies. Taking advantage of the rare network access, I have summarized my notes for this month. 1. Interrupt settings step: 1.    Set the peripheral interrupt prio
[Microcontroller]
PIC32 interrupt and oscillator configuration
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号