//////////////////////////////////////////////////////////////////////////////////////////////1/2,ClDIV= 1:128;/DOS= 1:1,FRC= 1:1,N2=2,N1=4 PLLFBD=75;/除数m=77;m=PLLFBD +2 ACLKCON= 0x0700;//OSC Del DAC:SELACLK=0,AUX OSC禁用,APSTLSCR & Gn;n除以1,AS您好,这里是:///////////////////////////////////////////////////(?)RCSEL=0μSuxTiNTIN WORKESEOSCCONH(0x03);DC1Lee=0;//关闭DAC INT。当与DMA一起使用时,DAC不能生成INTs DAC1CONC= 0x2102;//OFF,2补,除数CKDIVI=3(DACFDIV=2)100KSPs DAC1STAT=0x8505;/ /左通道,右。= 1)AC1DFLT=DAcDebug;/DAC1LIF=0;DAC1CONTITE;DAC1CONTITE;DAC1CONTITE;////////////////////////////////////////////////DMA段外,int LutB [LutbjLe++] 1,Apple(1);(或(主)C DMA0CONTITY;Chen=0;IEC0BIT。DMA0IE=0;IPC1通道关闭,中点关闭,如果FIFO空,位。DMA0COIP=7;DMA0CONC=0x2000;//字大小,写入外围设备,INT在完整传输块,正常操作,具有后增量,连续模式和乒乓关闭DMA0Req=0x00 4F;/INT由DAC1L DMA0STATA=Y-BuuthTiNoDMACOBUP(&LUTB〔1〕);/ /连接LUTB阵列DMA0PAD =(无符号未登录)LDAT-DMA0CNT=LutbxLe-1;//LutbjLe是100个样本,正弦周期IFS0BIT.DMA0IF=0;DMA0IE=1;;/激活INT///////////////////////////////////////////////其他:γ定义GeNa启动DMA0CONTITE,Chen=1;DMA0ReqBist.For=1;//Ge宏开始生成。DAC1LDAT;// DAC1AC1L ISR和中断不存在,因为不是NeDeD.DMA0ISR只停止生成(DMA0BITE,Chen=0),并事先用用户标记谢谢。
以上来自于百度翻译
以下为原文
Hi, here is:
////////////////////////////////////////////////// OSCILLATOR SECTION
// PLL (Using 8MHz XTAL)
CLKDIV=0x7002; // DOZE=1:128, DOZE OFF, FRC=1:1, N2=2, N1=4
PLLFBD=75; // Divisor M=77, M=PLLFBD+2
ACLKCON=0x0700; // OSC del DAC: SELACLK=0, Aux Osc disabled, APSTSCLR-> N divide by 1, ASRCSEL=0
__builtin_write_OSCCONH(0x03);
__builtin_write_OSCCONL(OSCCON | 0x01);
while((OSCCONbits.OSWEN==1) | (OSCCONbits.LOCK != 1));
OSCCONbits.CLKLOCK=1;
//////////////////////////////////////////////// DAC SECTION
IEC4bits.DAC1LIE=0; // Shut off dac INT. When used with DMA, DAC must not generate ints
DAC1CON=0x2102; // OFF, TWO's complement, Divisor CLKDIV=3 (DACFDIV=2) 100ksps
DAC1STAT=0x8505; // Left Channel ON, Right Channel OFF, Midpoint OFF, INT if FIFO empty,
DAC1DFLT=DACDEFAULT; // default value
IFS4bits.DAC1LIF=0;
DAC1CONbits.DACEN=1;
////////////////////////////////////////////// DMA SECTION
extern int lutb[LUTB_LEN+1]__attribute__((space(dma))); // in main.c
DMA0CONbits.CHEN=0;
IEC0bits.DMA0IE=0;
IPC1bits.DMA0IP=7;
DMA0CON=0x2000; // Word size, Write to peripheral, INT when complete transfer block, Normal operation, with Post-increment, Continuous mode and ping-pong off
DMA0REQ=0x004F; // INT by DAC1L
DMA0STA=__builtin_dmaoffset(&lutb[1]); // Connect lutb array
DMA0PAD=(volatile unsigned int)&DAC1LDAT; // with DAC1LDAT
DMA0CNT=LUTB_LEN-1; // LUTB_LEN is 100 samples, a sine period
IFS0bits.DMA0IF=0;
IEC0bits.DMA0IE=1; // Activate INT
////////////////////////////////////////////////////// others:
#define GEN_START DMA0CONbits.CHEN=1;DMA0REQbits.FORCE=1; // Macro to start generation
DAC1L ISR and interrupt does not exists because isn't needed.
DMA0 ISR only stops generating (DMA0bits.CHEN=0) with a user flag
Thank you in advance.
R.