* Function: P1.0 is used to control the on and off of the LED. The software delay is 50000 to flip P1.0. *
* *
* MSP430F2274 *
* ----------------- VCC 3.0v *
* /|\ | XIN|- ___ *
* | | XOUT|- | *
* --|RST P1.2|-->LED-----| *
* +--key-->|P1.3 P1.1|-->LED-----| *
* |---key-->|P1.4 P1.0|-->LED-----| *
* | ------------------- *
* GND *
* Author: Singel *
* Time: 2008-10-11 16:36:00 *
* Debugging environment: IAR For MSP430 Embedded Workbench v3.42A *
********************************************************************************/
#include"msp430x22x4.h"
unsigned char keybuffer;
unsigned char scanflag;
unsigned char TEMP_KEY;
void Do_Without_PORT_Register( void )
{
P1IE = 0x00;
P1IFG = 0x00;
P1IE = 0x00;
}
void PORT_init( void )
{
P1DIR |= (BIT0+BIT1+BIT2);
P1OUT |= (BIT0+BIT1+BIT2);
P1DIR &=~ (BIT4+BIT3);
P1IES &=~ (BIT4+BIT3);
P1IE |= (BIT4+BIT3);
P1IFG &=~ (BIT4+BIT3);
}
void key_procss ( void )
{
TEMP_KEY = TEMP_KEY&0X18;
switch(TEMP_KEY)
{
case 0x10: P1OUT ^= BIT0+BIT1+BIT2;break;
case 0x08: P1OUT ^= BIT0+BIT1+BIT2;break;
}
P1IE |= (BIT4+BIT3);
}
void main( void )
{
WDTCTL = WDTPW + WDTHOLD;
BCSCTL1 = CALBC1_12MHZ;
DCOCTL = CALBC1_12MHZ;
Do_Without_PORT_Register();
PORT_init();
_BIS_SR(GIE+LPM4_bits);
while(1)
{
if(scanflag)
{
scanflag = 0;
key_procss();
}
_BIS_SR(GIE + LPM4_bits);
}
}
#pragma vector = PORT1_VECTOR
__interrupt void PORT1_ISR ( void )
{
_BIC_SR_IRQ(LPM4_bits);
TEMP_KEY = P1IFG;
scanflag = 1;
P1IE &=~ (BIT4+BIT3);
P1IFG &=~ (BIT4+BIT3);
}
Previous article:Development of anti-interference measures for single chip microcomputer
Next article:MSP430 port line emulation I2C bus
- Popular Resources
- Popular amplifiers
- Operational Amplifier Practical Reference Handbook (Edited by Liu Changsheng, Zhao Mingying, Liu Xu, etc.)
- 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)
- Improved SSD algorithm for real-time target vehicle detection in ADAS
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
- Using CoreMark to test W806 performance
- A5 Why is there no ttyUSB in the dev directory?
- Low power MCU, crystal oscillator
- 【NXP Rapid IoT Review】+ Review Summary
- Gigabit RISC-V GD32VF103 debugging tool introduction
- Professional embedded software development: moving towards high-quality and efficient programming
- Recruitment: Ningbo listed auto parts company - motor control software development engineer
- Today at 10:00 AM, there will be a live broadcast with awards [Fujitsu empowers automotive electronics technology transformation]
- ESP32-Cam Programmer
- NXP Rapid IoT Review] + ⑤ Full Interpretation of NXP Rapid IoT Code, Finding Traces of RTC