找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1418|回复: 0
打印 上一主题 下一主题
收起左侧

求教: 24LE1 与MAX7219数码管模块的接口程序问题

[复制链接]
跳转到指定楼层
楼主
下面的的程序在STC15W408AS单片机上显示正常,与24LE1无线模块连接好后,数码管全亮显示,
逻辑分析仪抓取的波形如下:请高手指点一二,谢谢

程序如下:
   #include "Nordic\reg24le1.h"
#include "MAX7219.H"
#include "stdint.h"
#include "API.h"
unsigned char disbuf[8];

void delayms(unsigned int ms)
{
        unsigned char i=100,j;
        for(;ms;ms--)
        {
                while(--i)
                {
                        j=10;
                        while(--j);
                }
        }
}
                                                   
/*******************************************************************************************************
* Ãè  êö : ÅäÖà IO P0.0oíP0.1Îaêä3ö£¬P1.2oíP1.3Îaêäèë
* èë  2Î : ÎT
* ·μ»ØÖμ : ÎT
*******************************************************************************************************/
void IO_Init(void)
{       
        P0DIR =0x03;           //Åä  0000 0011
        P1DIR = 0x00;           //ÅäÖÃ0000 1100
        //P1CON=0X00;

}
void disp( )
{
   unsigned char i;
       
   for(i=0;i<8;i++)
   {
     Write_Max7219(i,disbuf[i]);
   }
}

void main()
{  
         IO_Init();                                                                        // I/O¿ú3õê¼»ˉ
          Init_MAX7219();  
   disp();
        while(1)
        {
                 disp();
                delayms(500);
        }
       
       
}
、、、、、、、、、、、、、、、、、、、、、、、、、、、、
#ifndef __MAX7219_H__
#define __MAX7219_H__

//#include <reg52.h>
#define uchar unsigned char
#define uint  unsigned int
//¶¨òåMax7219¶Ë¿ú
sbit Max7219_pinCLK = P1^6;
sbit Max7219_pinCS  = P1^5;
sbit Max7219_pinDIN = P1^4;
extern void delayms(unsigned int ms);

//--------------------------------------------
//1|Äü£oÏòMAX7219(U3)D′èë×Ö½ú
//èë¿ú2Îêy£oDATA
//3ö¿ú2Îêy£oÎT
//ËμÃ÷£o
void Write_Max7219_byte(uchar DATA)         
{
            uchar i;   
                Max7219_pinCS=0;               
            for(i=8;i>=1;i--)
          {                  
            Max7219_pinCLK=0;
            Max7219_pinDIN=DATA&0x80;
            DATA=DATA<<1;
            Max7219_pinCLK=1;
           }                                 
}
//-------------------------------------------
//1|Äü£oÏòMAX7219D′èëêy¾Y
//èë¿ú2Îêy£oaddress¡¢dat
//3ö¿ú2Îêy£oÎT
//ËμÃ÷£o
void Write_Max7219(uchar address,uchar dat)
{
     Max7219_pinCS=0;
         Write_Max7219_byte(address);           //D′èëμØÖ·£¬¼′êyÂë1ü±àoÅ
   Write_Max7219_byte(dat);               //D′èëêy¾Y£¬¼′êyÂë1üÏÔê¾êy×Ö
         Max7219_pinCS=1;                        
}

void Init_MAX7219(void)
{
Write_Max7219(0x09, 0xff);       //òëÂ뷽꽣oBCDÂë
Write_Max7219(0x0a, 0x03);       //áá¶è
Write_Max7219(0x0b, 0x07);       //é¨Ãè½çÏT£»4¸öêyÂë1üÏÔê¾
Write_Max7219(0x0c, 0x01);       //μôμçģ꽣o0£¬ÆÕí¨Ä£ê½£o1
Write_Max7219(0x0f, 0x01);       //ÏÔê¾2aêÔ£o1£»2aêÔ½áêø£¬Õy3£ÏÔê¾£o0
}
#endif

max7219.png (343.7 KB, 下载次数: 41)

max7219.png
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表