#include "MSP430F149.h"
#define uchar unsigned char
#define uint unsigned int
uchar LedData=0x80;
uchar num=50;//Interrupt 50 times to shift the LED right by one position
//Timer A initialization
void InitTimerB(){
TBCTL=TBSSEL1+ID1+ID0+MC0+TBCLR;//Select 1/8SMCLK to clear TAR
TBCCTL0=CCIE;//CCR0 interrupt enables comparison mode
TBCCR0=10000;//Time interval 10ms
}
//Timer A interrupt
#pragma vector =TIMERB0_VECTOR
__interrupt void TimerBINT(){
num--;
if(num==0){
LedData>>=1;//Shift right one bit
if(LedData==0x00) LedData=0x80;
P4OUT=LedData;//P4 port output data
num=50;//50 interrupts is 0.5s
}
}
void main(){
InitClock();//Initialize clock
InitTimerB();//Timer B initialization
P4DIR=0xFF;//P4 port output direction
_EINT();//Open interrupt
while(1);
}
Previous article:Robotics Tutorial 4: Infrared Tracking and LM339 Module
Next article:Detailed explanation and program of single chip microcomputer external interrupt
- Popular Resources
- Popular amplifiers
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- Adding a Raspberry Pi to a NumWorks Calculator
- Are 2G and 3G going to be phased out? Why is 3G being phased out faster than 2G?
- A strange problem occurred in a piece of code I wrote.
- Lichee RV 86 PANEL Review (3)——WSL single system solution environment construction
- Some problems encountered when using RSL10 and their solutions
- Isolated power supply topology (transformer introduced Buck and Boot topology)
- Why should the decoupling capacitor be placed close to the power supply when drawing PCB?
- TI C6000 Data Storage Processing and Performance Optimization
- The research institute is looking for backbones and team leaders in the field of electronics for 150,000-300,000 yuan
- EEWORLD University ---- Practical production of IoT projects: Bluetooth 4.0 BLE development - smart bulbs - universal remote control