⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 带spi接口的16位ad7705驱动程序 avr与虚拟仪器论坛 avrvi_com.htm

📁 有关于AD7705的众多详细资料
💻 HTM
📖 第 1 页 / 共 5 页
字号:
      href="http://bbs.avrvi.com/read-htm-tid-6472.html">带SPI接口的16位AD7705驱动程序</A></B></TD>
    <TD align=right>
      <TABLE 
      style="BORDER-RIGHT: #8c8e7b 1px solid; BORDER-TOP: #8c8e7b 1px solid; BACKGROUND: #ffffff; BORDER-LEFT: #8c8e7b 1px solid; BORDER-BOTTOM: #8c8e7b 1px solid; FONT-FAMILY: Tahoma, Verdana" 
      cellSpacing=1 cellPadding=1>
        <TBODY>
        <TR>
          <TD 
            style="FONT-SIZE: 7pt; BACKGROUND: #ff6500; COLOR: #ffffff">&nbsp;XML&nbsp;</TD>
          <TD style="FONT-SIZE: 7pt; BACKGROUND: #8c8e7b">&nbsp;<A 
            title=订阅本版面最新帖子 href="http://bbs.avrvi.com/rss.php?fid=30" 
            target=_blank><FONT color=#ffffff>RSS 2.0</FONT></A>&nbsp;</TD>
          <TD style="FONT-SIZE: 7pt; BACKGROUND: #8c8e7b">&nbsp;<A 
            title=通过手机访问论坛 href="http://bbs.avrvi.com/faq-htm-faqjob-2.html#5" 
            target=_blank><FONT 
      color=#ffffff>WAP</FONT></A>&nbsp;</TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR><!--ads begin-->
<TABLE cellSpacing=1 cellPadding=6 width="98%" align=center bgColor=#cccccc>
  <TBODY>
  <TR align=middle>
    <TD class=f_one width="25%"><A style="FONT-SIZE: 12px; COLOR: #0000ff" 
      href="http://shop34452654.taobao.com/" target=_blank>AVRVI的淘宝店</A></TD>
    <TD class=f_one width="25%"><A style="COLOR: #6600cc" 
      href="http://shop.avrvi.com/category-41-b0.html" 
      target=_blank>AVR单片机学习套餐</A></TD>
    <TD class=f_one width="25%"><A style="FONT-SIZE: 18px; COLOR: blue" 
      href="http://shop.avrvi.com/goods-160.html" target=_blank>EasyAVR M128开发板 
      SK</A></TD>
    <TD class=f_one width="25%"><A style="FONT-SIZE: 14px; COLOR: green" 
      href="http://shop.avrvi.com/" 
  target=_blank>国内最专业AVR开发工具商城</A></TD></TR></TBODY></TABLE><BR><!--ads end-->
<TABLE cellSpacing=0 cellPadding=1 width="98%" align=center>
  <TBODY>
  <TR>
    <TD align=left></TD>
    <TD align=right><A href="http://bbs.avrvi.com/post-htm-fid-30.html"><IMG 
      src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/post.gif"></A> <A 
      href="http://bbs.avrvi.com/post-htm-action-vote-fid-30.html"><IMG 
      src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/vote.gif"></A> <A 
      href="http://bbs.avrvi.com/post-htm-action-reply-fid-30-tid-6472.html"><IMG 
      src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/reply.gif"></A> 
  </TD></TR></TBODY></TABLE>
<FORM name=delatc action=masingle.php?action=delatc method=post><INPUT 
type=hidden value=30 name=fid> <INPUT type=hidden value=6472 name=tid> 
<TABLE 
style="BORDER-RIGHT: #cccccc 1px solid; BORDER-TOP: #cccccc 1px solid; BORDER-LEFT: #cccccc 1px solid" 
cellSpacing=0 cellPadding=1 width="98%" align=center>
  <TBODY>
  <TR>
    <TD class=head align=left>--&gt; <B>本页主题:</B> 带SPI接口的16位AD7705驱动程序</TD>
    <TD class=head align=right><A 
      onclick="Addtoie('http://bbs.avrvi.com/read.php?fid=30&amp;tid=6472','AVR与虚拟仪器论坛 AVRVi.com--带SPI接口的16位AD7705驱动程序')" 
      href="http://bbs.avrvi.com/#">加为IE收藏</A> | <A 
      href="http://bbs.avrvi.com/profile-htm-action-favor-job-add-tid-6472.html">收藏主题</A> 
      | <A 
      href="http://bbs.avrvi.com/job-htm-rd_previous-1-fid-30-tid-6472-fpage-0-goto-previous.html">上一主题</A> 
      | <A 
      href="http://bbs.avrvi.com/job-htm-rd_previous-1-fid-30-tid-6472-fpage-0-goto-next.html">下一主题</A> 
    </TD></TR></TBODY></TABLE><A name=tpc>
<TABLE style="TABLE-LAYOUT: fixed; WORD-WRAP: break-word" cellSpacing=1 
cellPadding=0 width="98%" align=center bgColor=#cccccc>
  <TBODY>
  <TR>
    <TD 
    style="PADDING-RIGHT: 5px; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; PADDING-TOP: 5px" 
    vAlign=top width="20%" bgColor=#ffffff height="100%"><FONT face=Gulim 
      color=#000066><B>铜河</B></FONT><BR>
      <TABLE cellSpacing=0 cellPadding=0 width="98%">
        <TBODY>
        <TR>
          <TD align=middle><BR><BR></TD></TR></TBODY></TABLE><BR><IMG alt=技术群用户 
      src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/qq.jpg"> <IMG 
      alt=优秀斑竹奖 src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/2.gif"> 
      <BR><IMG src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/5.gif"> 
      <BR>级别: <FONT color=#555555>论坛版主</FONT><BR>精华: <A 
      href="http://bbs.avrvi.com/search-htm-authorid-2408-digest-1.html" 
      target=_blank><FONT color=green><B>7</B></FONT></A> <BR>发帖: <FONT 
      color=green><B>511</B></FONT><BR>威望: <FONT color=#984b98><B>746 
      点</B></FONT><BR>金钱: <FONT color=#984b98><B>5971 VI</B></FONT><BR>贡献值: 
      <FONT color=red><B>253 点</B></FONT><BR>技术积分: <FONT color=#0033ff><B>31 
      点</B></FONT><BR>在线时间:125(小时)<BR>注册时间:1970-01-01<BR>最后登录:2008-09-06 </TD>
    <TD vAlign=top width="80%" bgColor=#ffffff height="100%">
      <TABLE style="TABLE-LAYOUT: fixed; WORD-WRAP: break-word" height="100%" 
      cellSpacing=0 cellPadding=4 width="99%" align=center>
        <TBODY>
        <TR>
          <TD vAlign=top bgColor=#ffffff colSpan=6><A 
            href="http://bbs.avrvi.com/profile-htm-action-show-uid-2408.html"><IMG 
            alt=查看作者资料 
            src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/profile.gif" 
            align=absMiddle></A> <A 
            href="http://bbs.avrvi.com/message-htm-action-write-touid-2408.html"><IMG 
            alt=发送短消息 
            src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/message.gif" 
            align=absMiddle></A> <A 
            href="http://bbs.avrvi.com/sendemail-htm-action-tofriend-tid-6472.html"><IMG 
            alt=推荐此帖 
            src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/emailto.gif" 
            align=absMiddle></A> <A 
            href="http://bbs.avrvi.com/post-htm-action-quote-fid-30-tid-6472-pid-tpc-article-0.html"><IMG 
            alt=引用回复这个帖子 
            src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/quote.gif" 
            align=absMiddle></A> <A 
            href="http://bbs.avrvi.com/post-htm-action-modify-fid-30-tid-6472-pid-tpc-article-0.html"><IMG 
            src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/edit.gif" 
            align=absMiddle></A> <BR><BR><SPAN 
            class=tpc_title>带SPI接口的16位AD7705驱动程序</SPAN><BR><BR><SPAN 
            class=tpc_content>在为“我心飞翔”设计的板子上,应用了双通道16位AD转换器,此AD转换精度高、速度快、具有自校准。经努力,调通了其中一路,现共享,但愿能起到抛砖引玉的作用。<BR>/****************************************<BR>* 
            &nbsp; &nbsp; &nbsp; &nbsp;AD7705在M16下驱动程序 &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp;*<BR>* 文 件 名:AD7705.c &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>* 描 &nbsp; 
            述:16位∑-Δ模数转换器 &nbsp; &nbsp; &nbsp; &nbsp;*<BR>* 作 &nbsp; 者:铜河 &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp;*<BR>* 建立日期:2007年12月27日 &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp;*<BR>* 版 &nbsp; 本:V2007.01 &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>* 
            修改日期:2007年12月27日 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;*<BR>* 控制芯片:Mega16 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>* 时钟频率:7.3728MHz 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;*<BR>* 波 特 率:9600BPS &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>* 联接方式:AD7705 ________ 
            M16 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*<BR>* 片 &nbsp; 
            选:CS_7705 _______ PA4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;*<BR>* 复 &nbsp; 位:RESET _________ PA5 &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp;*<BR>* 数据有效:DRRY __________ PB3 &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; 
            &nbsp;*<BR>****************************************/<BR>#include 
            &lt;iom16v.h&gt;<BR>#include &lt;macros.h&gt;<BR>#include 
            "delay.h"<BR><BR>//控制端口定义<BR>//端口操作定义<BR>#define CS_7705 &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp;PA4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //AD7705的片选接在PA4<BR>#define 
            SET_CS_7705 &nbsp; &nbsp;PORTA |= 1&lt;&lt;CS_7705<BR>#define 
            CLR_CS_7705 PORTA &amp;= ~(1&lt;&lt;CS_7705)<BR><BR>#define RET 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;PA5 &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            //AD7705的复位接在PA5<BR>#define SET_RET &nbsp; &nbsp; &nbsp; &nbsp;PORTA 
            |= 1&lt;&lt;RET<BR>#define CLR_RET &nbsp; &nbsp; &nbsp; &nbsp;PORTA 
            &amp;= ~(1&lt;&lt;RET)<BR><BR>#define DRRY &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp;PB3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; //AD7705的数据有效接在PB3<BR>#define DRRY_7705 &nbsp; 
            &nbsp;(PINB &amp; (1&lt;&lt;DRRY))<BR><BR>//SPI接口初始化函数<BR>void 
            spi_init(void)<BR>&nbsp; &nbsp;{<BR>&nbsp; &nbsp;DDRB |= 
            (1&lt;&lt;PB5)|(1&lt;&lt;PB7); &nbsp; &nbsp; &nbsp; &nbsp;//设置MOSI 
            和SCK 为输出<BR>&nbsp; &nbsp;DDRB &amp;= ~(1&lt;&lt;PB6); &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//MISO为输入<BR>&nbsp; 
            &nbsp;SPCR = (1&lt;&lt;SPE)|(1&lt;&lt;MSTR); &nbsp; &nbsp; &nbsp; 
            &nbsp;//使能SPI主机模式fck/4<BR>&nbsp; 
            &nbsp;}<BR><BR>//写入AD7705一字节函数<BR>//入口:data 需写入的字节数据<BR>void 
            wr_byte(unsigned char data)<BR>&nbsp; &nbsp;{<BR>&nbsp; &nbsp;SPDR = 
            data; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp;//启动数据传输<BR>&nbsp; &nbsp;while (!(SPSR &amp; 
            (1&lt;&lt;SPIF))) &nbsp; &nbsp; &nbsp; &nbsp;//等待传输结束 <BR>&nbsp; 
            &nbsp; &nbsp; &nbsp;{<BR>&nbsp; &nbsp; &nbsp; &nbsp;;<BR>&nbsp; 
            &nbsp; &nbsp; &nbsp;}<BR>&nbsp; 
            &nbsp;}<BR><BR>//读出AD7705数据函数<BR>//出口:读出的2字节数据<BR>unsigned int 
            rd_7705(void)<BR>&nbsp; &nbsp;{<BR>&nbsp; &nbsp;unsigned int temp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//定义临时变量<BR>&nbsp; &nbsp;wr_byte(0x38); &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//选择读数据寄存器,1通道<BR>&nbsp; &nbsp;SPDR = 0; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp;//启动数据传输<BR>&nbsp; &nbsp;while (!(SPSR &amp; 
            (1&lt;&lt;SPIF))) &nbsp; &nbsp; &nbsp; &nbsp;//等待传输结束 <BR>&nbsp; 
            &nbsp; &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp;<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp;;<BR>&nbsp; &nbsp; &nbsp; &nbsp;}<BR>&nbsp; &nbsp;temp 
            = SPDR&lt;&lt;8; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp;//读取高字节<BR>&nbsp; &nbsp;<BR>&nbsp; &nbsp;SPDR = 
            0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//启动数据传输<BR>&nbsp; &nbsp;while 
            (!(SPSR &amp; (1&lt;&lt;SPIF))) &nbsp; &nbsp; &nbsp; &nbsp;//等待传输结束 
            <BR>&nbsp; &nbsp; &nbsp; &nbsp;{ &nbsp; &nbsp; &nbsp; 
            &nbsp;<BR>&nbsp; &nbsp; &nbsp; &nbsp;;<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp;}<BR>&nbsp; &nbsp;temp |= SPDR; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//读取低字节<BR>&nbsp; 
            &nbsp;return(temp);<BR>&nbsp; 
            &nbsp;}<BR><BR>//判断有无数据函数<BR>//出口:读出的2字节数据<BR>unsigned int 
            ad7705(void)<BR>&nbsp; &nbsp;{<BR>&nbsp; 
            &nbsp;if(DRRY_7705==0)<BR>&nbsp; &nbsp; &nbsp; &nbsp;{<BR>&nbsp; 
            &nbsp; &nbsp; &nbsp;return(rd_7705());<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp;}<BR>&nbsp; &nbsp;else<BR>&nbsp; &nbsp; &nbsp; 
            &nbsp;{<BR>&nbsp; &nbsp; &nbsp; &nbsp;return(0);<BR>&nbsp; &nbsp; 
            &nbsp; &nbsp;}<BR>&nbsp; &nbsp;}<BR><BR>//AD7705初始化函数<BR>void 
            init_7705(void)<BR>&nbsp; &nbsp;{<BR>&nbsp; 
            &nbsp;spi_init();<BR>&nbsp; &nbsp;DDRA |= 
            (1&lt;&lt;CS_7705)|(1&lt;&lt;RET); &nbsp; &nbsp;//定义端口方向<BR>&nbsp; 
            &nbsp;DDRB &amp;= ~(1&lt;&lt;DRRY);<BR>&nbsp; &nbsp;PORTB|= 
            1&lt;&lt;DRRY;<BR>&nbsp; &nbsp;CLR_CS_7705; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//片选有效<BR>&nbsp; &nbsp;CLR_RET; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//复位端低有效<BR>&nbsp; &nbsp;delay_ms(500); &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//保持500MS低电平<BR>&nbsp; &nbsp;SET_RET; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//复位端回复高<BR>&nbsp; &nbsp;delay_ms(1);<BR>&nbsp; 
            &nbsp;wr_byte(0x20); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp;//选择时钟寄存器<BR>&nbsp; &nbsp;wr_byte(0x0C); 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//50HZ的转换频率<BR>&nbsp; &nbsp;wr_byte(0x10); &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//选择设置寄存器<BR>&nbsp; &nbsp;wr_byte(0x44); &nbsp; &nbsp; &nbsp; 
            &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 
            &nbsp;//自校准模式,增益为1,单极性<BR>&nbsp; &nbsp;}</SPAN><BR></TD></TR>
        <TR vAlign=bottom bgColor=#ffffff>
          <TD colSpan=6>
            <TABLE cellSpacing=1 cellPadding=4 bgColor=#cccccc>
              <TBODY>
              <TR>
                <TD class=t_one><A href="http://www.avrvi.com/index_avr.html" 
                  target=_blank>本站原创AVR单片机新手入门教程!</A></TD></TR></TBODY></TABLE></TD></TR>
        <TR vAlign=bottom bgColor=#ffffff>
          <TD class=smalltxt colSpan=5><FONT color=red>[楼 主]</FONT> | 
            <B>Posted:</B> 01-28 23:06</TD>
          <TD class=smalltxt align=right><A href="javascript:scroll(0,0)"><IMG 
            alt=顶端 
            src="带SPI接口的16位AD7705驱动程序 AVR与虚拟仪器论坛 AVRVi_com.files/top.gif"></A> 
          </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -