我最近刚学MSP430F6638的ADDA模块,尝试着编写了下面一段采集程序来采集100Hz的正弦波,但是不知道为什么程序很不稳定,有时能采集出波形,有时采不出,暂停程序就会出现No source available for "0x4"的问题,我想知道是程序编写上有问题还是其他方面的问题!我用的编译软件是CCS5.5。
附程序:
#include <msp430f6638.h>
void Clk_init(void)
{
while(BAKCTL&LOCKIO)
BAKCTL&=~LOCKIO;
P7SEL|=BIT2+BIT3;
UCSCTL6&=~(XT1OFF);
UCSCTL6&=~XT2OFF;
do
{
UCSCTL7&=~(XT2OFFG+XT1LFOFFG+XT1HFOFFG+DCOFFG);
SFRIFG1&=~OFIFG;
}
while(SFRIFG1&OFIFG);
UCSCTL6&=~XT2DRIVE0;
UCSCTL4|=SELA_0+SELM_5+SELS_5;
}
void Timer_init(void)
{
TA0CCR0=999;
TA0CCTL1|=OUTMOD_3;
TA0CCR1=500;
TA0CTL=TASSEL_2+MC_1+TACLR;
}
void ADC_init(void)
{
REFCTL0&=~REFMSTR;
P6SEL|=BIT0;
ADC12CTL0=ADC12ON+ADC12SHT0_2+ADC12REF2_5V+ADC12REFON;
ADC12CTL1=ADC12SSEL_2+ADC12CONSEQ_2+ADC12SHS_1+ADC12SHP;
ADC12CTL2=ADC12RES_2;
ADC12MCTL0=ADC12INCH_0+ADC12SREF_1
ADC12CTL0|=ADC12ENC;
}
void DAC_init(void)
{
DAC12_0CTL0=DAC12IR+DAC12SREF_0+DAC12AMP_5+DAC12ENC+DAC12CALON+DAC12OPS;
}
void DMA_init(void)
{
DMACTL0=DMA0TSEL__ADC12IFG;
DMA0CTL=DMADT_4+DMADSTINCR_0+DMAEN;
__data16_write_addr((unsigned short)&DMA0SA,(unsigned long)&ADC12MEM0);
__data16_write_addr((unsigned short)&DMA0DA,(unsigned long)&DAC12_0DAT);
DMA0SZ=0x01;
}
void main(void)
{
WDTCTL=WDTPW+WDTHOLD;
Clk_init();
Timer_init();
ADC_init();
DMA_init();
DAC_init();
__bis_SR_register(CPUOFF + GIE);
__no_operation();
}
此帖出自
小平头技术问答
一周热门 更多>