/*--------------------------------------------------------*/
/* SPECTRUM DIGITAL INC. */
/*--------------------------------------------------------*/
/* Offchip DAC test for EVM320LF2407 */
/* This test requires a loopback connector */
/*--------------------------------------------------------*/
/* */
/* filename: dac.c */
/* last update: 08/18/2005 by: LYP for 2407 */
/*--------------------------------------------------------*/
#include "dac.h"
#include "LF2407REGS.h"
#define MS_TIME_LOOP 0x0385
volatile unsigned int dacdata;
#define MAX_DAC 4
unsigned int wait_ms( volatile unsigned int delay_val )//延时1ms程序
{
unsigned int i;
unsigned int ms_ctr;
for ( i = 0; i < delay_val; i++ )
{
ms_ctr = MS_TIME_LOOP;
while ( ms_ctr )
{
ms_ctr--;
}
}
return( delay_val );
}
void write_dac(unsigned int dac_num, unsigned int dac_val) //往DA通道写数
{
unsigned int write_dac_status;
if ( dac_num < MAX_DAC )
{
dacdata = dac_val; /* put in global location */
switch (dac_num)
{
case DAC0:
OUTMAC( _DAC0, dacdata);
break;
case DAC1:
OUTMAC( _DAC1, dacdata);
break;
case DAC2:
OUTMAC( _DAC2, dacdata);
break;
case DAC3:
OUTMAC( _DAC3, dacdata);
break;
}
asm(" nop" );
asm(" nop" );
asm(" nop" );
asm(" nop" );
asm(" nop" );
asm(" nop" );
OUTMAC( _DAC_XFER, dacdata); /* just need a write, any data */
}
}
void initsys(){
asm(" setc SXM ");
asm(" clrc OVM ");
asm(" clrc CNF ");
*SCSR1=0x83fe;
*WDCR =0x0e8;
*IMR =0x000f;
*IFR =0xffff;
*WSGR =0x00;
}
void inline disable(){
asm(" setc INTM ");
}
void inline enable(){
asm(" clrc INTM ");
}
void interrupt nothing()
{return;}
void main() //程序输出方波,周期200ms
{
disable();
initsys();
while(1)
{write_dac(0,4090);write_dac(1,4090);write_dac(2,4090);write_dac(3,4090);
wait_ms(100);
write_dac(0,0);write_dac(1,0);write_dac(2,0);write_dac(3,0);
wait_ms(100);};
}
DAC.rar_2407 dac.p_DAC_TMS320LF2407_ccs code dac7611
版权申诉
115 浏览量
2022-09-23
23:52:40
上传
评论
收藏 46KB RAR 举报
四散
- 粉丝: 52
- 资源: 1万+