资源简介
MSP430F149 TB输出频率可调PWM波 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
代码片段和文件信息
#include “MSP430x14x.h“
#define uchar unsigned char
#define uint unsigned int
void PWM(unsigned char x)
{
TBCTL = TBSSEL_2+ TBCLR; // ACLK 清除 TAR
TBCCR0 = x - 1; // PWM 周期 52kHz
TBCCTL1 = OUTMOD_7;
TBCCR1 = 9; //
TBCCTL2 = OUTMOD_7;
TBCCR2 = 9; //
TBCCTL3 = OUTMOD_7;
TBCCR3 = 9; //
TBCCTL4 = OUTMOD_7;
TBCCR4 = 9; //
TBCCTL5 = OUTMOD_7;
TBCCR5 = 9; //
TBCCTL6 = OUTMOD_7;
TBCCR6 = 9; // 占空比 128/512=0.25
P4DIR|=BIT6+BIT1+BIT2+BIT3+BIT4+BIT5;
P4SEL|=BIT6+BIT1+BIT2+BIT3+BIT4+BIT5;
TBCTL |= MC0; // TA 增计数模式
}
void delay(uint z)
{
uint xy;
for(x=z;x>0;x--);
for(y=1000;y>0;y--);
}
int main( void )
{
WDTCTL = WDTPW + WDTHOLD;
uchar i=10;
P1DIR &= 0xfe;
P1OUT |= 0x00;
while(1)
{
if((P1IN&BIT0)==0) //如果有键被按下
{
delay(2000); //延时消抖
if((P1IN&BI
- 上一篇:ADI的EDID编辑工具
- 下一篇:数据库系统概论总结(非常好的一份资料)
评论
共有 条评论