#include"msp430g2553.h"
#define cSMCLK 12000000
#define SIN_F 200 //定义输出正弦波频率为200hz#define SIN_NUM 16 //定义正弦波查表采样点数
const unsigned int sin_table[SIN_NUM]={64,88,108,122,127,122,108,88,64,39,19,5,0,5,19,39};
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; //关闭看门狗BCSCTL1 = CALBC1_12MHZ; //设置定时器时钟为12mhz
DCOCTL = CALDCO_12MHZ; //DCO频率设置为12mhzDCOCTL = DCOCTL&0xE0;TA1CTL|= TASSEL_2+MC_1; //TA1设置为增计数模式,时钟为SMCLK(12mhz)
TA1CCTL1|= OUTMOD_7; //TA1模块设置为模式7输出P2SEL|= BIT1; //P2.1为输出口
P2DIR= BIT1;
TACCR0=128; //pwm周期为128hz
}
void Timer0_A_Init()
{
TA0CCTL0 = CCIE;
TA0CCR0 = cSMCLK/SIN_F/SIN_NUM;
TA0CTL = TASSEL_2 + MC_1; //TA0为增计数模式,时钟为SMCLK(12mhz)
_EINT(); //开中断
}
//读表
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0(void)
{
_disable_interrupts();
Change__Duty();_enable_interrupts();
}
Susan Yang:
e2echina.ti.com/…/572672
我会在测试后回复,请不要重复发帖,谢谢
gaoyang9992006:
程序完整吗,怎么看不到你的表数据在哪儿被调用?
user6327139:
回复 gaoyang9992006:
好像确实是change_duty()函数没有定义