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
- 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)
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
- 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
MoreDaily News
- 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
Guess you like
- The problem of not being able to find playback data occurs when configuring openpilot on Ubuntu
- Discussion: When 5G encounters an earthquake
- [GD32E231 DIY Contest] 06. Automatic fish feeding robot: ADC/DMA/TIMER0/serial port
- Are there any recommendations for 5V boost switching chips?
- Excellent materials, no points required: Album of previous competition questions of the National Undergraduate Electronic Design Competition
- How to determine the grounding method for a circuit board built with circuit modules?
- 50% charge in 5 minutes! How powerful is the much-hyped GaN fast charging?
- A comprehensive analysis of the principles of various lightning protection circuits
- Basic circuit design tree for RF microwave circuit engineering
- Common Linux commands in the Corelink SinA33 development board virtual machine