1147 views|0 replies

3836

Posts

19

Resources
The OP
 

Launchpad msp430 PWM experiment [Copy link]

#include "msp430g2231.h" #define PWM BIT6 int main( void ) { unsigned int i; unsigned char flag; flag = 1; i = 0; // Stop watchdog timer to prevent time out reset WDTCTL = WDTPW + WDTHOLD; TACTL = TASSEL_2 + TACLR;//Timer clock source selection clear timer CCR0 = 1500; TACCTL1 = OUTMOD_7;//Output mode selection: PWM reset/set CCR1 = 0; P1DIR |= BIT6;//P1.6 is set to output P1SEL |= PWM;//P1.6 is set to PWM output port function TACTL |= MC_1;//Working mode is increase mode while(1) { if(TACTL & BIT0) { TACTL &= ~BIT0; if(flag)i++; else i--; if(i > 1500) flag = 0; if(i == 0) flag = 1; CCR1 = i; //Change duty cycle } } }

This post is from Microcontroller MCU
 

Guess Your Favourite
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