#include "msp430x26x.h"
#include "TA_Timer.h"
#include "TA_PWM.h"
#include "TB_PWM.h"
#include <string.h>
#include <stdio.h>
#include "LCD12864.h"
unsigned int glbcnt=0;
char TB_PWM_Init(char Clk,char Div,char Channel,char Mode);
char TA_PWM_Init(char Clk,char Div,char Mode1,char Mode2);
int a[ ];
int at1;//设置TA_PWM_1通道变量
int at2;//设置TA_PWM_2通道变量
int b=1000;//设置TB_PWM_1通道变量
int b1=1000;//设置TB_PWM_2通道变量
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
TA_PWM_Init('s',1,'P','P');//TA设置PWM通道1的输出模式从P1.2输出;设置PWM通道1的输出模式从P1.3输出
TB_PWM_Init('S',1,1,'P');//TB设置PWM通道1高电平PWM输出;设置PWM通道1的输出模式从P4.1输出
TB_PWM_Init('S',1,2,'P');//TB高电平PWM输出;从P4.2输出
LCD_Init();
TA_Timer_Init(20,'M');
LCD_Init();
_EINT();
// void TA_Timer_ISR(void)
while(1)
{
glbcnt=glbcnt++;
at1=1000;
if(glbcnt>3)
{at2=1000;
at1=0;}
if(glbcnt>9)
{
at1=1000;
at2=0;
}
TA_PWM_OutPutWave(1,at1,100,'K');//设置TA PWM通道1方波的占空比
TA_PWM_OutPutWave(2,at2,100,'K');//设置TA PWM通道1方波的占空比
TB_PWM_OutPutWave(1,b,100,'K');//设置TB PWM通道1方波的占空比
TB_PWM_OutPutWave(2,b1,100,'K');//设置TB PWM通道2方波的占空比
LCD_Printf(1,"TA_1占空比:%3d,% ",at1);
LCD_Printf(2,"TA_2占空比:%3d,% ",at2);
LCD_Printf(3,"%3d, ",glbcnt);
if(glbcnt>12)
glbcnt=0; //每过87*20ms一次
};
} |