?? max7219芯片驅(qū)動(dòng)程序----pic18fxx2與c51平臺(tái)_蛋蛋_新浪博客.htm
字號(hào):
?<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0052)http://blog.sina.com.cn/s/blog_3f84c12d01000b4q.html -->
<HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD><TITLE>MAX7219芯片驅(qū)動(dòng)程序----pic18fxx2與C51平臺(tái)_蛋蛋_新浪博客</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META http-equiv=X-UA-Compatible content=IE=EmulateIE7>
<META
content="愛(ài)一個(gè)人,蛋蛋,PIC18FXX2Max7219.c///////////////////////////////////////////////////////////////////////////////////////////////////author:qingxiaokun//version:1.0//Time:08.8.12am////////////////////////////////////////////////////////////////////////////////////////////////#include'pic18fxx2.h'#defineDINRB5#defineCSRB4#defineCLKRB1voiddelay(unsignedchari){unsignedcharj=0;for(;i>0;i--){for(j=0;j<100;j++){}"
name=description>
<META content=愛(ài)一個(gè)人,蛋蛋,校園生活 name=keywords>
<SCRIPT>
var scope = {
$uid : "1065664813",
$PRODUCT_NAME : "blog",
$pageid : "article",
$key : "e9be6c11c685789d8bc8557572b26b62",
$sort_id : "152",
$loadconf : true,
$flag2008 : "0",
$articleid : "3f84c12d01000b4q" ,
$isCommentAllow : "1"
};
var $encrypt_code = "818a6bd931f802f8bae3fc8ccf45200c";
var config = {"common":{"t":"5_3","r":0,"head":[],"bg":[],"pageset":0,"invitationset":0},"private":{"cms":0,"blogsize":0,"ad":0,"sms":0,"adver":0},"component":{"c1":[901,8,1001,10,1004,1003,1007,12,5,1002],"c2":[],"c3":[2,1,14],"x":3},"product":{"c":21,"j":15}};
var fav = {"3f84c12d01000b4q":"cd95ad04df3ea9d8fd52f1a9287584b0"} ;
</SCRIPT>
<SCRIPT src="MAX7219芯片驅(qū)動(dòng)程序----pic18fxx2與C51平臺(tái)_蛋蛋_新浪博客.files/boot.js"
type=text/javascript></SCRIPT>
<SCRIPT type=text/javascript>loadCss();</SCRIPT>
<SCRIPT
src="MAX7219芯片驅(qū)動(dòng)程序----pic18fxx2與C51平臺(tái)_蛋蛋_新浪博客.files/platform_tray.compressed.js"></SCRIPT>
<LINK href="MAX7219芯片驅(qū)動(dòng)程序----pic18fxx2與C51平臺(tái)_蛋蛋_新浪博客.files/im.css" type=text/css
rel=stylesheet><!--# block name="blk737369" --><!--# endblock --><!--#include file="/hits?act=4&aid=${aid}" stub="blk737369" -->
<META content="MSHTML 6.00.2900.3527" name=GENERATOR></HEAD>
<BODY>
<DIV id=sinatopbar>
<SCRIPT type=text/javascript>
<!--
document.write(SinaSysTray.getHTML());
//-->
</SCRIPT>
</DIV>
<SCRIPT type=text/javascript>
<!--
SinaSysTray.base_init({
"type" : scope.$PRODUCT_NAME || "",
"uid" : $UID || "0"
});
//-->
</SCRIPT>
<DIV class=wrapper>
<DIV class=headpic100 id=headpic100>
<DIV class=headpic950 id=headPic950>
<DIV class=ntoptitle id=ntoptitle>
<DIV class=ntopns id=blogTitle>
<DIV class=ntitname id=blogname><A
href="http://blog.sina.com.cn/xiaokei">愛(ài)一個(gè)人</A> </DIV>
<DIV class=ntitsite>http://blog.sina.com.cn/xiaokei<A class=CP_a_fuc
id=SubscribeNewRss onclick="return false;"
href="http://blog.sina.com.cn/s/blog_3f84c12d01000b4q.html#">[<CITE>訂閱</CITE>]</A></DIV></DIV></DIV></DIV>
<DIV class=termenubg></DIV>
<DIV class=termenu>
<DIV class=termenuc id=clone_template>
<DIV class=termenutag>
<DIV class=user>
<DIV class=userhead><A href="http://blog.sina.com.cn/xiaokei"><IMG
src="MAX7219芯片驅(qū)動(dòng)程序----pic18fxx2與C51平臺(tái)_蛋蛋_新浪博客.files/50.jpg"></A></DIV>
<DIV class=username><A style="CURSOR: hand"
href="http://blog.sina.com.cn/xiaokei"><SPAN id=nav_name></SPAN></A></DIV></DIV>
<DIV class=promenu>
<LI class=on><SPAN id=nav_blog><A
href="http://blog.sina.com.cn/xiaokei">博客</A></SPAN>
<LI><SPAN id=nav_photo><A
href="http://photo.blog.sina.com.cn/xiaokei">相冊(cè)</A></SPAN>
<LI><SPAN id=nav_music><A
href="http://music.sina.com.cn/m/1065664813">音樂(lè)</A></SPAN>
<LI><SPAN id=nav_vblog><A
href="http://you.video.sina.com.cn/xiaokei">播客</A></SPAN>
<LI><SPAN id=nav_tiezi><A
href="http://profile.blog.sina.com.cn/xiaokei">個(gè)人中心</A></SPAN> <!-- <li><span id="nav_quanzi"><a href="http://q.sina.com.cn/m/xiaokei">圈子</a></span></li>--></LI></DIV></DIV>
<DIV class=termenutxt>
<DIV class=tmtcen>
<DIV class=floatLeft><SPAN><A
href="http://blog.sina.com.cn/xiaokei">首頁(yè)</A></SPAN><SPAN
class=linesp></SPAN><SPAN><A
href="http://blog.sina.com.cn/s/articlelist_1065664813_0_1.html">博文</A></SPAN><SPAN
class=linesp></SPAN><SPAN><A
href="http://blog.sina.com.cn/s/favourites_1065664813_1.html">收藏</A></SPAN><SPAN
class=linesp></SPAN><SPAN><A
href="http://profile.blog.sina.com.cn/circle.php?uid=1065664813&page=1&type=3">博客圈</A></SPAN><!--<span > <a href="http://blog.sina.com.cn/lm/rank/index.html" target="_blank">排行榜</a></span>--></DIV>
<DIV class=floatRight></DIV></DIV></DIV></DIV></DIV></DIV>
<DIV class=contentLayout>
<DIV class="column_2 floatLeft">
<DIV class="components730 SinaAd_hide" id=advertise_top></DIV>
<DIV class=components730>
<DIV class=component>
<DIV class=componentBar><SPAN class="floatRight articleFontSize"
id=articleFontManage>字體大小:<A onclick="changeFontSize(2);return false;"
href="http://blog.sina.com.cn/s/">大</A><B>中</B><A
onclick="changeFontSize(0);return false;"
href="http://blog.sina.com.cn/s/">小</A></SPAN> <SPAN class=title>正文</SPAN>
</DIV>
<DIV class="componentContent article">
<DIV class=comconblog>
<DIV class=articleTitle>
<DIV style="DISPLAY: inline"><B
id=t_3f84c12d01000b4q>MAX7219芯片驅(qū)動(dòng)程序----pic18fxx2與C51平臺(tái)</B><SPAN
class=time>(2007-08-12 10:45:45)</SPAN></DIV></DIV>
<DIV class=articleTag>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD>
<SCRIPT>var $tag='校園生活';var $tag_code='fe3274e06ac3294e9413f5e8b89edc56';</SCRIPT>
標(biāo)簽:<A class=tag
href="http://uni.sina.com.cn/c.php?t=blog&k=%D0%A3%D4%B0%C9%FA%BB%EE&ts=bpost&stype=tag"
target=_blank>校園生活</A><WBR> </TD>
<TD vAlign=top align=right width=250></TD></TR></TBODY></TABLE></DIV>
<DIV class=articleContent id=articleBody>
<DIV><FONT color=#0000ff><U> <WBR>PIC18FXX2</U></FONT></DIV>
<DIV> <WBR></DIV>
<DIV><FONT color=#0000ff> <WBR><FONT face=宋體>Max7219.c</FONT></FONT></DIV>
<P><FONT face=宋體
color=#000000>/////////////////////////////////////////////////////////////////////////////////////////////////<BR>//author:qingxiaokun<BR>//version:1.0<BR>//Time:08.8.12am<BR>////////////////////////////////////////////////////////////////////////////////////////////////<BR>#include
"pic18fxx2.h"<BR>#define <WBR> DIN RB5<BR>#define <WBR> CS
RB4<BR>#define CLK RB1</FONT></P>
<P><FONT face=宋體 color=#000000>void delay(unsigned char
i)<BR>{<BR> <WBR>unsigned char
j=0;<BR> <WBR>for(;i>0;i--)<BR> <WBR>{<BR> <WBR> <WBR>for(j=0;j<100;j++)<BR> <WBR> <WBR>{}<BR> <WBR>}<BR>}<BR>/////////////////////////////////////////////////////////////////////////////////////////////<BR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR>
//>>數(shù)據(jù)傳輸格式.<</<BR>void Max7219_Led(unsigned char codes0,unsigned
char codes1)<BR>{<BR> <WBR>unsigned char bitter=0x80,i=0;<BR> <WBR>
CS=0;<BR> <WBR>for(i=0;i<8;i++)<BR> <WBR>{<BR> <WBR> <WBR>if((codes0&bitter)==bitter)<BR> <WBR> <WBR>DIN=1;<BR> <WBR> <WBR>else<BR> <WBR> <WBR>DIN=0;<BR> <WBR> <WBR>CLK=1;<BR> <WBR> <WBR>CLK=0;<BR> <WBR> <WBR>bitter=bitter>>1;<BR> <WBR>}<BR> <WBR>bitter=0x80;<BR> <WBR>for(i=0;i<8;i++)<BR> <WBR>{<BR> <WBR> <WBR>if((codes1&bitter)==bitter)<BR> <WBR> <WBR>DIN=1;<BR> <WBR> <WBR>else<BR> <WBR> <WBR>DIN=0;<BR> <WBR> <WBR>CLK=1;<BR> <WBR> <WBR>CLK=0;<BR> <WBR> <WBR>bitter=bitter>>1;<BR> <WBR>}<BR> <WBR>CS=1;<BR> <WBR>CLK=1;<BR>}<BR>/////////////////////////////////////////////////////////////////////////////////////////////////////////<BR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR>
/* <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR>
通用初始化及顯示八位數(shù)碼.0~9,blank,-,H,E,L,P <WBR> <WBR> <WBR> <WBR> <WBR> <WBR>
*/ <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR><BR>void
Max7219_Initial()<BR>{<BR> <WBR> Max7219_Led(0xf,1);
//數(shù)碼管全點(diǎn)亮,時(shí)長(zhǎng)10ms;<BR> <WBR> delay(10);<BR> <WBR>
Max7219_Led(0xf,0);<BR> <WBR>
Max7219_Led(0xb,0x7);//數(shù)碼官全部可以顯示。<BR> <WBR>
Max7219_Led(0xa,0x6);//數(shù)碼官亮度為最大。<BR> <WBR>
Max7219_Led(0x9,0xff);//BCD碼是顯示,每一位代表一個(gè)數(shù)碼位是否譯碼顯示,但只有四種工作方式:00,01,0f,ff<BR> <WBR>
Max7219_Led(0xc,1);<BR>}<BR>void Max7219_Display(unsigned char
*p)//指針指向一個(gè)數(shù)量為8的數(shù)組.<BR>{<BR> <WBR>unsigned char
i=0;<BR> <WBR>for(i=0;i<8;i++)<BR> <WBR>{<BR> <WBR> <WBR>Max7219_Led(i+1,*p);<BR> <WBR> <WBR>p++;<BR> <WBR>}<BR>}<BR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR>
/* <WBR> <WBR> <WBR> <WBR> <WBR>
結(jié)束 <WBR> <WBR> <WBR>
*/<BR>/////////////////////////////////////////////////////////////////////////////////////////////////////////<BR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR>
/* <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR> <WBR>
顯示0~9,a,b,c,d,e,f,-,blank <WBR> <WBR> <WBR> */<BR>void
Max7219_Display_Others(unsigned char t,unsigned char p,unsigned char dp)
//t為要顯示的數(shù)碼管位.p為要顯示的值,dp為是否有小數(shù)點(diǎn)<BR>{<BR> <WBR>unsigned char
pt=0x80;<BR> <WBR>Max7219_Led(0x9,0x00);<BR> <WBR>if(dp==1)<BR> <WBR>pt=0x80;<BR> <WBR>else<BR> <WBR>pt=0x0;<BR> <WBR>switch
(p)<BR> <WBR>{<BR> <WBR> <WBR>case
0x0:Max7219_Led(t,0xfe|pt);break;<BR> <WBR> <WBR>case
0x1:Max7219_Led(t,0x30|pt);break;<BR> <WBR> <WBR>case
0x2:Max7219_Led(t,0x6d|pt);break;<BR> <WBR> <WBR>case
0x3:Max7219_Led(t,0x79|pt);break;<BR> <WBR> <WBR>case
0x4:Max7219_Led(t,0x33|pt);break;<BR> <WBR> <WBR>case
0x5:Max7219_Led(t,0x5b|pt);break;<BR> <WBR> <WBR>case
0x6:Max7219_Led(t,0x5f|pt);break;<BR> <WBR> <WBR>case
0x7:Max7219_Led(t,0x70|pt);break;<BR> <WBR> <WBR>case
0x8:Max7219_Led(t,0xff|pt);break;<BR> <WBR> <WBR>case
0x9:Max7219_Led(t,0x7b|pt);break;<BR> <WBR> <WBR>case
0xa:Max7219_Led(t,0x77|pt);break;<BR> <WBR> <WBR>case
0xb:Max7219_Led(t,0xf1|pt);break;<BR> <WBR> <WBR>case
0xc:Max7219_Led(t,0x4e|pt);break;<BR> <WBR> <WBR>case
0xd:Max7219_Led(t,0x3d|pt);break;<BR> <WBR> <WBR>case
0xe:Max7219_Led(t,0x4f|pt);break;<BR> <WBR> <WBR>case
0xf:Max7219_Led(t,0x17|pt);break;<BR> <WBR> <WBR>case
'h':Max7219_Led(t,0x37|pt);break;<BR> <WBR> <WBR>case
'l':Max7219_Led(t,0x0e|pt);break;<BR> <WBR> <WBR>case
'p':Max7219_Led(t,0x67|pt);break;<BR> <WBR> <WBR>case '
':Max7219_Led(t,0x00|pt);break;<BR> <WBR> <WBR>case
'-':Max7219_Led(t,0x01|pt);break;<BR> <WBR> <WBR><BR> <WBR>}<BR> <WBR><BR>}<BR>void
Max7219_Display_Others_Char(unsigned char
*p)//指針指向一個(gè)數(shù)量為8的數(shù)組.<BR>{<BR> <WBR>unsigned char
i=0;<BR> <WBR>for(i=0;i<8;i++)<BR> <WBR>{<BR> <WBR> <WBR>Max7219_Display_Others(i+1,*p,0);<BR> <WBR> <WBR>p++;<BR> <WBR>}<BR>}</FONT></P>
<P><FONT face=宋體 color=#0000ff><U>頭文件 <WBR></U></FONT></P>
<P><FONT face=宋體>Max7219.h</FONT></P>
<P><FONT face=宋體 color=#000000><FONT face=宋體>#include "pic18fxx2.h"<BR>#define
RD0 DIN<BR>#define RD1 CS<BR>#define RD2 CLK<BR>void delay(unsigned char
i);<BR>void Max7219_Led(unsigned char codes0,unsigned char codes1);<BR>void
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -