1. 本次使用esay5509开发板,具体做这个板子叫做大道科技。

2. 5509有2个ADC的输入引脚,就是2个采集通道

DSP5509的ADC实验-LMLPHP

3. 看下ADC的寄存器

DSP5509的ADC实验-LMLPHP

4. 看下代码中怎么引用ADC的寄存器的,这种写法很少用,但是在DSP中很常见的。

 ioport unsigned int *ADCCTL1=(unsigned int *)0x6800;
ioport unsigned int *ADCDATA1=(unsigned int *)0x6801;
ioport unsigned int *ADCCLKDIV1=(unsigned int *)0x6802;
ioport unsigned int *ADCCLKCTL1=(unsigned int *)0x6803;
#define ADCCTL (*ADCCTL1)
#define ADCDATA (*ADCDATA1)
#define ADCCLKDIV (*ADCCLKDIV1)
#define ADCCLKCTL (*ADCCLKCTL1)

5. 主程序比较简单

 main()
{
int i;
unsigned int uWork; EnableAPLL(); InitADC();
PLL_Init();
while ( )
{
for ( i=;i<;i++ )
{
ADCCTL=0x8000; // 启动AD转换,通道0
do
{
uWork=ADCDATA;
} while ( uWork&0x8000 );
nADC0[i]=uWork&0x0fff;
}
for ( i=;i<;i++ )
{
ADCCTL=0x9000; // 启动AD转换,通道1
do
{
uWork=ADCDATA;
} while ( uWork&0x8000 );
nADC1[i]=uWork&0x0fff;
}
asm( " nop"); // break point 在这里设断点
}
} void InitADC()
{
ADCCLKCTL=0x23; // 4MHz ADCLK
ADCCLKDIV=0x4f00;
}

6. 在程序中注意到一个细节,怎么直接给寄存器赋值的,看下面*( ioport volatile unsigned short* )0x1f00 = 4;这种写法很重要,一定要掌握。

 void EnableAPLL( )
{
/* Enusre DPLL is running */
*( ioport volatile unsigned short* )0x1f00 = ;
wait( );
*( ioport volatile unsigned short* )0x1f00 = ;
// MULITPLY
*( ioport volatile unsigned short* )0x1f00 = 0x3000;
// COUNT
*( ioport volatile unsigned short* )0x1f00 |= 0x4F8;
wait( );
//*( ioport volatile unsigned short* )0x1f00 |= 0x800
// MODE
*( ioport volatile unsigned short* )0x1f00 |= ;
wait( );
// APLL Select
*( ioport volatile unsigned short* )0x1e80 = ;
// DELAY
wait( );
}
05-11 22:49