<?xml version="1.0" encoding="gbk"?> <rss version="2.0"><channel> <title>定阅帖子更新</title> <link>http://www.broadkey.com.cn/XML.ASP</link><description>TEAM Board - 意得法电子</description> <copyright>TEAM 2.0.5 Release</copyright><generator>TEAM Board by TEAM5.Cn Studio</generator> <ttl>30</ttl><item><link>http://www.broadkey.com.cn/Thread.asp?tid=38 </link><title>MCF52233ADC</title><author>ellen</author><pubDate>2009-11-24 20:46:05</pubDate><description><![CDATA[<p>MCF52233的ADC功能很是强大，有8个ADC通道,有两个ADC模块，这两个ADC模块可以设置为并行工作模式(但对每个模块还是顺序转换的）或者是顺序的模式。MCF52235 ADC模块的主要特性：12位的精度，频率最高为5MHz，采样率高达1.66MPS，单通道采样转换时间1.7微秒，额外转换时间1.2微秒，差分功能。控制寄存器1：CTRL1为16位寄存器，主要位STOP0可以设置是否停止，START0使模块开始工作，SYNC0定义模块可以由外部信号触发工作，EOSIE0、ZCIE、LLMTIE、HLMTIE定义各种中断使能，CHNCFG定义是否使用差分，SMODE转换模式。控制寄存器2：CTRL2为16位寄存器，DIV设置时钟的分频。若工作在并行转换模式，则CTRL2和CTRL1含义基本相同，但是控制的是ADC B模块。&nbsp;ADZCC寄存器：和ADOFSn配合使用，过零标志，可以设置符号由正变负或由负变正触发中断。ADLST1和ADLST2：可以设置队列转换的先后顺序，既先先采样哪个通道。采样禁止寄存ADSDIS：该寄存器与ADLST1,ADLST2配合使用，对应位为1允许采样。状态寄存器ADSTAT：CIP0和CIP1指A和B模块是正在转换还是处于空闲，EOSI1和EOSI0表示转换完成中断来临，ZCI过零中断，LLMTI最低限制中断，HLMTI最高限制中断，RDYn指示采样是否就绪。<br />
&nbsp;限制状态寄存器ADLSTAT：指示是否超越高低限制。过零状态寄存器ADZCSTAT：过零状态。结果寄存器ADRSLTn：16位寄存器RSLT存放12位结果，还提供一个SEXT符号位。低三位未用。高低限制寄存器ADHLMTn和ADLLMTn：设置高低限制，离开这个限制将产生中断（如果允许）。偏移量寄存器ADOFSn：是跟过零状态有关的值。参考电压寄存器CAL：选择参考电压源。ADC的详细说明和一些细节问题请阅读英文的PDF文档。下面贴出一个关于ADC的程序以供参考：<br />
<br />
#include&quot;ADC.h&quot;</p>
<p>void ADCInit(void)<br />
{<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; //config CTRL1&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp; MCF_ADC_CTRL1 =MCF_ADC_CTRL1_STOP0|MCF_ADC_CTRL1_SYNC0|MCF_ADC_CTRL1_EOSIE0<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |MCF_ADC_CTRL1_CHNCFG(0)|MCF_ADC_CTRL1_SMODE(0);<br />
&nbsp;&nbsp;&nbsp;&nbsp; MCF_ADC_CTRL2= MCF_ADC_CTRL2_DIV(9);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp; MCF_ADC_ADLST1=0x37; //Set the list register<br />
&nbsp;&nbsp; MCF_ADC_ADLST2=0x4567;<br />
&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; //Set the sample Disable Register(ADSDIS)<br />
&nbsp;&nbsp;&nbsp; // MCF_ADC_ADSDIS=MCF_ADC_ADSDIS_DS1;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MCF_ADC_ADSDIS=MCF_ADC_ADSDIS_DS2;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; //Set the lowest limit , highest limit<br />
&nbsp;&nbsp;&nbsp; MCF_ADC_ADLLMT0 = 0x2222;<br />
&nbsp;&nbsp;&nbsp; MCF_ADC_ADHLMT0 = MCF_ADC_ADHLMT_HLMT(0xffff);<br />
&nbsp;&nbsp; // MCF_ADC_ADLLMT1 = 0;<br />
&nbsp;&nbsp; // MCF_ADC_ADHLMT1 = MCF_ADC_ADHLMT_HLMT(0x4444);<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp; // MCF_ADC_ADLLMT2 = 0;<br />
&nbsp;&nbsp; // MCF_ADC_ADHLMT2 = MCF_ADC_ADHLMT_HLMT(0xffff);<br />
&nbsp;&nbsp; // MCF_ADC_ADLLMT3 = 0;<br />
&nbsp;&nbsp; // MCF_ADC_ADHLMT3 = MCF_ADC_ADHLMT_HLMT(0xffff);<br />
&nbsp;&nbsp; // MCF_ADC_ADLLMT4 = 0;<br />
&nbsp;&nbsp; // MCF_ADC_ADHLMT4 = MCF_ADC_ADHLMT_HLMT(0xffff);<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; //set the offset regisers<br />
&nbsp;&nbsp; // MCF_ADC_ADOFS0 = 0x0fff;<br />
&nbsp;&nbsp; // MCF_ADC_ADOFS1 = 0;<br />
&nbsp; //&nbsp; MCF_ADC_ADOFS2 = 0;<br />
&nbsp; //&nbsp; MCF_ADC_ADOFS3 = 0;<br />
&nbsp; //&nbsp; MCF_ADC_ADOFS4 = 0;<br />
&nbsp; //&nbsp; MCF_ADC_ADOFS5 = 0;<br />
&nbsp; //&nbsp; MCF_ADC_ADOFS6 = 0;<br />
&nbsp; //&nbsp; MCF_ADC_ADOFS7 = 0;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;// Disables zero crossing flag<br />
&nbsp; // MCF_ADC_ADZCC |= MCF_ADC_ADZCC_ZCE0(0X2);</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp; MCF_ADC_POWER = 0xd4;//PUDELY=13,PD2=1<br />
&nbsp;&nbsp;</p>
<p>&nbsp;&nbsp;&nbsp; ///// MCF_ADC_CTRL1 &amp;=~MCF_ADC_CTRL1_STOP0;//CLEAR STOP0,PREPARE FOR&nbsp; STARTING<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp; //wait A power_up finish<br />
&nbsp;&nbsp;&nbsp; while(MCF_ADC_POWER&amp;MCF_ADC_POWER_PSTS0)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;;<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;&nbsp; //wait B power_up finish<br />
&nbsp;&nbsp;&nbsp; while(MCF_ADC_POWER&amp;MCF_ADC_POWER_PSTS1)<br />
&nbsp;&nbsp;&nbsp; {<br />
&nbsp;&nbsp;&nbsp; &nbsp;;<br />
&nbsp;&nbsp;&nbsp; }<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;<br />
&nbsp;<br />
}</p>
<p>&nbsp;</p>
<p>void ADCStart(void)<br />
{<br />
&nbsp;&nbsp; //MCF_ADC_CTRL1&amp;=~MCF_ADC_CTRL1_STOP0;<br />
&nbsp;MCF_ADC_CTRL1|=MCF_ADC_CTRL1_START0;<br />
&nbsp;<br />
&nbsp;MCF_ADC_ADRSLT0=0X1111;</p>]]></description></item></channel></rss>