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)
void InitADC();
void wait( unsigned int cycles );
void EnableAPLL( );
unsigned int nADC0[512];
main()
{
int i;
unsigned int uWork;
EnableAPLL();
//InitADC();
PLL_Init(132);
while ( 1 )
{
for ( i=0;i<512;i++ )
{
ADCCTL=0x8000; // 启动AD转换,通道0
do
{
uWork=ADCDATA;
} while (uWork&0x8000);
nADC0[i]=uWork&0x0fff;
}
asm( " nop"); // break point 在这里设断点
}
}
void InitADC()
{
ADCCLKCTL=0x23; // 4MHz ADCLK,SystemClkDiv=35
ADCCLKDIV=0xf600;//SampTimeDiv=246,ConvRateDiv=0
}
void wait( unsigned int cycles )
{
int i;
for ( i = 0 ; i < cycles ; i++ ){ }
}
void EnableAPLL( )
{
/* Enusre DPLL is running */
*( ioport volatile unsigned short* )0x1f00 = 4;
wait( 25 );
*( ioport volatile unsigned short* )0x1f00 = 0;
// MULITPLY
*( ioport volatile unsigned short* )0x1f00 = 0x3000;
// COUNT
*( ioport volatile unsigned short* )0x1f00 |= 0x4F8;
wait( 25 );
//*( ioport volatile unsigned short* )0x1f00 |= 0x800
// MODE
*( ioport volatile unsigned short* )0x1f00 |= 2;
wait( 30000 );
// APLL Select
*( ioport volatile unsigned short* )0x1e80 = 1;
// DELAY
wait( 60000 );
}
|