2658 views|1 replies

2015

Posts

0

Resources
The OP
 

Msp430f149 microcontroller controls stepper motor C language program [Copy link]

#include     typedef unsigned int uint; typedef unsigned char uchar; #define PWM BIT2 void int_clk() { uchar i; BCSCTL1&=~XT2OFF; //Turn on the XT oscillator BCSCTL2|=SELM1+SELS;//MCLK 8M and SMCLK 1M do { IFG1 & = ~OFIFG; //Clear the 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|=PWM; //Select P12 as PWM output P1DIR|=PWM; TACCR0=800; //PWM signal period 10KHz TACCR1=400; //Duty cycle 1:1 TACCTL1=OUTMOD0+OUTMOD1+OUTMOD2; //Output mode selection TACTL|=TASSEL1+MC0; } void main() [size =4]{ WDTCTL=WDTPW+WDTHOLD; //Turn off the watchdog int_clk(); //Initialize the clock [size=4 ] int_pwm(); //Initialize PWM while(1);//End } This routine is based on The PWM of the msp430f149 microcontroller controls the rotation of the stepper motor, with P1.2 port as the PWM output port, the PWM signal cycle is 10KHZ, and the duty cycle is 1:1.

This post is from Microcontroller MCU

Latest reply

It would be nice if you could share more.  Details Published on 2019-5-5 10:57
 

2618

Posts

0

Resources
2
 
It would be nice if you could share more.
This post is from Microcontroller MCU
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list