发 帖  
[话题] msp430F169产生三相交流电
2017-8-22 21:06:29  1218
分享
#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
2017-8-22 21:06:29   评论

只有小组成员才能发言,加入小组>>

84个成员聚集在这个小组

加入小组

创建小组步骤

关闭

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

快速回复 返回顶部 返回列表