[话题] msp430F169产生三相交流电

pangsg1 ( 楼主 ) 2017-8-22 21:06:29  显示全部楼层
#include <msp430x16x.h>  
const long int num_sin[72]={                 
  0x800,0x8b2,0x963,0xa12,0xabc,0xb61,0xc00,0xc96,0xd24,0xda8,0xe20,0xe20,0x8ed,
  0xeed,0xf84,0xfba,0xf84,0xf40,0xeed,0xed8,0xe20,0xda8,0xd24,0xc96,0xc00,0xb61,
  0xabc,0xa12,0x963,0x8b2,0x800,0x74d,0x69c,0x5ed,0x543,0x49e,0x400,0x369,0x2db,
  0x257,0x1df,0x172,0x112,0x0bf,0x07b,0x450,0x01f,0x007,0x000,0x007,0x01f,0x045,
  0x07b,0x0bf,0x112,0x172,0x1df,0x257,0x2db,0x369,0x400,0x49e,0x543,0x5ed,0x69c,
  0x74d};
const unsigned short int N1=72;
const unsigned short int N2=50;
const unsigned long int F=800256;
short int buf_TA,N_sin,N_sin1;
unsigned int cont;
void init_TB(void)
{
buf_TA=(int)(F/(N1*N2));
TBCCR0=buf_TA;
TBCTL=TBSSEL_2+TBCLR+SHR_0;
TBCCTL0=CCIE;
TBCTL|=MC0;}
#pragma vector = TIMERB0_VECTOR
__interrupt void timer_b0(void){{
DAC12_0DAT=NUM_RAM0[N_sin];
N_sin1=N_sin+24;
if(N_sin1>1)
    { N_sin1=N_sin1-72;}

DAC12_1DAT=NUM_SIN0[N_sin];
N_sin=N_sin+1;
if(N_sin==72)
{
N_sin=0;
}
_NOP();
}}
#pragma vector=WDT_VECTOR
__interrupt void watchdog_timer(void)
{
cont=cont+1;
P1OUT=0x10;
if(cont==4)
{
cont=0;
}
}
void main(void)
{
unsigned char tmpv_1;
WDTCTL=WDT_ADLY_250;
BCSCTL1=XT2OFF+SELS;
BCSCTL2=SELS;
P1DIR=0x80;
ADC12CTL0=REF2_5V+REFON;
DAC12_0CTL=DAC12IR+DAC12AMP_5+DAC12ENC;
DAC12_1CTL=DAC12IR+DAC12AMP_5+DAC12ENC;
DAC12_0DAT=0x80;
DAC12_1DAT=0x80;
IE1|=WDTIE;
init_TB();
_EINT();
cont=0;
for(tmpv_1=0;tmpv_1<72;tmpv_1++)
{
NUM_RAM0[tmpv_1]=NUM_SIN0[tmpv_1];
NUM_RAM1[tmpv_1]=NUM_SIN1[tmpv_1];}
xdata=50;
aindata=setdata=24;
void init();
{
WDTCTL=WDTPW+WDTHOLD;
BCSCTL1=DIVA1+DIVA0;
DCOCTL=DCO2+DCO1+DCO0;
TACTL=TASSEL1+TACLR+ID_3;
CCR0=65535;
CCTL0=CCIE;
TACTL=MC1;
}}
真是我的代码 但不能通过编译,请大神指导一下

0个回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则


关闭

站长推荐上一条 /9 下一条

小黑屋|手机版|Archiver|电子发烧友 ( 粤ICP备14022951号-2 )

GMT+8, 2018-7-17 02:21 , Processed in 0.247715 second(s), 21 queries , Memcache On.

Powered by 电子发烧友网

© 2015 bbs.elecfans.com

微信扫描
快速回复 返回顶部 返回列表