51/AVR单片机技术驿站!  <在线翻译>     便利工具    特色网址   无弹窗、无插件的绿色站点...  英才招聘   学历查询  喜欢>>收藏我站 

当前位置:首页 > 单片机技术文章 > 51单片机 > 详细内容
力源的PS7219数码管驱动芯片的C51源程序
发布时间:2009/7/21  阅读次数:533  字体大小: 【】 【】【
以下是ps7219.h文件源码:
#define                  addr_bit_1                           0x01
#define                  addr_bit_2                           0x02
#define                  addr_bit_3                           0x03
#define                  addr_bit_4                           0x04
#define                  addr_bit_5                           0x05
#define                  addr_bit_6                           0x06
#define                  addr_bit_7                           0x07
#define                  addr_bit_8                           0x08
#define                  addr_trans_mode                  0x09
#define                  addr_light_con                  0x0a
#define                  addr_scan_count                  0x0b
#define                  addr_close                           0x0c
#define                  addr_echo_test                  0x0d

sbit                   ps7219_pin_RST =    P1^4;
sbit                  ps7219_pin_LOAD =    P1^5;
sbit                  ps7219_pin_DIN         =    P1^6;
sbit                  ps7219_pin_CLK         =    P1^7;

void ps7219_init();
void ps7219_reset();
void ps7219_echo(unsigned char da_1 da_2 da_3 da_4);
void ps7219_send_data(unsigned char addr da);
void ps7219_delay(void);

以下是ps7219.c文件源码:
#include "reg51.h"
#include "ps7219.h"

void ps7219_reset()
{
unsigned char i;
ps7219_pin_RST=0;
for(i=0;i<125;i++)
ps7219_delay();
ps7219_pin_RST=1;
for(i=0;i<255;i++)
ps7219_delay();
ps7219_pin_RST=0;
for(i=0;i<125;i++)
ps7219_delay();
}

void ps7219_init()
{
ps7219_reset();
ps7219_send_data(addr_scan_count 0 0 0 0 ps7219_echo(unsigned char da_1 da_2 da_3 da_4)
{
        ps7219_send_data(0x01 da_1);
        ps7219_send_data(0x02 da_2);
   ps7219_send_data(0x03 da_3);
   ps7219_send_data(0x04 da_4);

}

void ps7219_send_data(unsigned char addr da)
{
unsigned char i byte_out;
byte_out=addr;
ps7219_pin_DIN=1;
ps7219_pin_CLK=1;
ps7219_pin_LOAD=0;

for(i=0;i<8;i++)
{
ps7219_pin_CLK=1;
ps7219_pin_DIN=(bit)(byte_out&0x80);
byte_out=byte_out<<1;
ps7219_pin_CLK=0;
ps7219_delay();

}

ps7219_pin_CLK=1;
byte_out=da;
for(i=0;i<7;i++)
{
ps7219_pin_CLK=1;
ps7219_pin_DIN=(bit)(byte_out&0x80);
byte_out=byte_out<<1;
ps7219_pin_CLK=0;
ps7219_delay();

}
ps7219_pin_CLK=1;
ps7219_pin_LOAD=1;
ps7219_pin_DIN=(bit)(byte_out&0x80);
ps7219_pin_CLK=0;
ps7219_delay();
ps7219_pin_CLK=1;
}

void ps7219_delay(void)
{
unsigned char i;
for(i=0;i<125;i++)
{}

}
我要评论
  • 匿名发表
  • [添加到收藏夹]
  • 发表评论:(匿名发表无需登录,已登录用户可直接发表。) 登录状态:未登录
最新评论
所有评论[0]
    暂无已审核评论!

网站导航 管理登陆 ┊ 免责声明 问题反馈  友链说明
本站部分内容来自网络共享资源,如有冒犯您的权利请来信告之删除或纠正!
不得对本站进行复制、盗链或镜像,转载内容须获得同意或授权;欢迎友情链接、站务合作!

    我要报警 Alexa
 mcusy_cn#126.com (请把#改成@) 交流:522422171
本站学习交流群:138..158(高级群1-)、77930286(高级群2)、61804809(群3)
Copyright© MCUSY All Rights Reserved
本站网警备案号: WZ36040002485
  ICP备案证书号:粤ICP备09034963号