MSP430F149 TimerA outputs pwm signal
Keywords:MSP430F149 TimerA
Reference address:MSP430F149 TimerA outputs pwm signal C program code
Note the corresponding relationship between the register settings and the PWM signal output pins: P1.2-TA1, TACCR1, TACCTL1; P1.3-TA2, TACCR2, TACCTL2.
#include
#define uint unsigned int
#define uchar unsigned char
void int_clk()
{
uchar i;
BCSCTL1 &= ~XT2OFF; //Turn on XT oscillator
BCSCTL2 |= SELM1+SELS; //MCLK is 8MHz, SMCLK is 8MHz
do
{
IFG1&=~OFIFG; //Clear oscillation error flag
for(i=0;i<100;i++)
_NOP(); //Delay waiting
}
while((IFG1&OFIFG)!=0); //If the flag is 1, continue to loop and wait
IFG1&=~OFIFG;
}
void int_pwm()
{
P1SEL |= BIT2 + BIT3 ; //Select p1.2-TA1, P1.3-TA2 as the second function of PWM output
P1DIR |= BIT2 + BIT3 ;
TACCR0 = 800; //PWM signal frequency 10KHZ
TACCR1 = 400; // Duty cycle 1:1
TACCTL1 = OUTMOD_7;
TACCR2 = 400 ;
TACCTL2 = OUTMOD_7;
TACTL |= TASSEL1 +ID1 + ID0 + MC0 ; //Select SMCLK increase mode
}
void main()
{
WDTCTL = WDTPW + WDTHOLD;
int_clk();
int_pwm();
while(1);
}
Previous article:MSP430F149 and 1602LCD module program
Next article:msp430F149 and cc2500 communication enable USART1, SPI initialization
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
MoreDaily News
- "Cross-chip" quantum entanglement helps build more powerful quantum computing capabilities
- Ultrasound patch can continuously and noninvasively monitor blood pressure
- Ultrasound patch can continuously and noninvasively monitor blood pressure
- Europe's three largest chip giants re-examine their supply chains
- Europe's three largest chip giants re-examine their supply chains
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Design of automotive LIN communication simulator based on Renesas MCU
- When will solid-state batteries become popular?
- Adding solid-state batteries, CATL wants to continue to be the "King of Ning"
Guess you like
- Watch IPTV from IPTV
- CC3220 Wireless MCU LaunchPad Development Kit Design
- MOTOROLA 16-bit MCU Selection Guide
- 422 Driver Output Level
- P87LPC768 OTP MCU Data Sheet
- NB-IoT application classification and technical characteristics analysis
- "Operational Amplifier Parameter Analysis and LTspice Application Simulation" 2. Chapter 2 Bias Current
- I2C Timing
- CUBEMX configures six-step square wave drive BLDC
- Resource Download: IoT technology is everywhere in the home