MSP430 MCU external interrupt

Publisher:DreamySerenityLatest update time:2016-06-03 Source: eefocusKeywords:MSP430 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
MSP430F149 has rich external interrupt resources. All 16 IO ports, including P1 and P2, can be used as external interrupt sources. We will focus on how to use them.

To make an IO port as an interrupt source for an external interrupt, three settings must be made. First, the direction of the IO port must be set to input; second, the trigger mode of the external interrupt must be selected, that is, whether it is a rising edge trigger or a falling edge trigger; third, the interrupt of the IO port must be enabled.

For example, if we want to set P1.0 as an external interrupt source, we can set it like this:

P1DIR&= ~BIT0; //Direction is set as input

 P1IES |= BIT0; //trigger mode setting

P1IE |= BIT0; // Enable interrupt

In the trigger mode setting, 0 is rising edge trigger and 1 is falling edge trigger. After the setting is completed, you can use the external interrupt triggered by the falling edge or rising edge of the P1.0 port.

It should be noted that if interrupts are used in a design program, the general interrupt must be enabled before using the interrupt. The statement to enable the general interrupt in the IARfor430 environment is: _EINT(); Just like if we want to turn on the three lights A, B, and C, we need to turn on the main power switch in addition to turning on the switches of the three lights A, B, and C, otherwise the lights will not light up. The corresponding statement to turn off the general interrupt is: _DINT(); 

Keywords:MSP430 Reference address:MSP430 MCU external interrupt

Previous article:Msp430 MCU clock module
Next article:Design based on stepper motor driver MC33991

Latest Microcontroller Articles
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号