原创 YLP2440 DAC测试

2009-5-20 08:53 2405 7 7 分类: MCU/ 嵌入式
https://static.assets-stash.eet-china.com/album/old-resources/2009/5/20/0192d499-fe95-4442-9c99-03695ed17c76.rar
0af74c7e-c1aa-40e1-b724-09a779cc3cb7.jpg

1.设置ADCCON
enable A/D converter prescaler,即往[14](PRSCEN)置一,设置 A/D converter prescaler value,[13:6](PRSCVL),并选择Analog input channel select,[5:3](SEL_MUX)。
其中A/D converter freq. = GCLK/(prescaler+1) = 1MHz
rADCCON = (1<<14)| (preScaler << 6) | ((ch&0x7) << 3);
2.Start ADC and check if ENABLE_START is low
ENABLE_START([0]),A/D conversion starts by enable. If READ_START is enabled, this value is not valid.
0 = No operation
1 = A/D conversion starts and this bit is cleared after the start-up.
    rADCCON |= 0x1;
    while (rADCCON & 0x1);        //check if ENABLE_START is low
3.Check if ECFLG(End of Conversion flag) is high
ECFLG([15])——End of conversion flag(Read only)
0 = A/D conversion in process
1 = End of A/D conversion
    while (! (rADCCON & 0x8000) );    //check ECFLG
4.返回结果
ADCDAT0/1([9:0]),XPDATA(Normal ADC)/YPDATA
return ((int)rADCDAT0 & 0x3ff);

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
7
关闭 站长推荐上一条 /3 下一条