本次的实验室DAC的转换实验,主要的流程是:DA转换所设定的值并用串口显示在PC上,然后将转换的值送入AD,将AD转换后的值显示在PC上。
#include "includes.h"
void myDelay (INT32U ulTime)
{
INT32U i;
i = 0;
while (ulTime--) {
for (i = 0; i < 2000; i++);
}
}
int main (void)
{
int i,num;
SystemCoreClockUpdate();
uart0Init(9600,0,0,8,1);
printf("DAC generated take SineWave Test ");
dacInit();
adcInit();
while (1) {
for(i=0;i<100;i++)
{
dacTrigger(i);
printf("DAC value = %d ",i);
myDelay(5);
num = adcGetUint();
printf("ADC value = %d \n",num);
myDelay(500);
if(i==100) i=0;
}
}
}
|