找回密码
 立即注册

QQ登录

只需一步,快速开始

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

哪位大神能给我看一下我的单片机代码为啥不能循环点亮点阵屏?

[复制链接]
跳转到指定楼层
楼主
ID:964940 发表于 2021-9-8 18:06 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
#include <stdio.h>
#include <REG52.H>
#include <INTRINS.H>

sbit        LT = P3^2;
sbit        EN = P3^3;

void Led_Display1row(unsigned char row);

void Delay_ms(unsigned int Cnt)
{
        unsigned int t;
        while(Cnt--)
        {
                t=100;
                while(--t);
        }
}

void UARTInit()
{
        SCON = 0;
        ES = 0;
}

void main()
{        
//        unsigned char i;
        
        UARTInit();
        EN = 0;        
        LT = 0;
        
//        for(i=0;i<10;i++)
//        {
//                TI = 0;
//                SBUF = 0x00;
//                while(TI==0);
//        }
//        LT = 1;
//        LT = 0;
//        
//        while(1)
//        {
//                for( i=0;i<16;i++ )
//                {
//                        P2 = i;
//                        Delay_ms(1000);
//                }
//        }
        

        
                Led_Display1row(1);
         
}
unsigned char idata Led_Matrix[16][10]=
{
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
        0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};

void Led_Display1row(unsigned char row)
{
        unsigned char col;
        EN=1;
        LT=0;
        for(col=0;col<10;col++)
        {
                TI=0;
                SBUF= Led_Matrix[row][9-col];
                while(TI==0);
                while(1)
        {
                for(row=0;row<16;row++ )
                {
                        P2=row;
                        Delay_ms(1000);
                }
        }

        }
        LT=1;
        LT=0;
        EN=0;
                  
}





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

使用道具 举报

沙发
ID:155507 发表于 2021-9-8 18:36 | 只看该作者
又没有图,也没有描述清楚也不知道你的电路图是怎样的,
程序都是针对特定芯片编写的,

没有具体故障现象,谁能看出哪里出错了
回复

使用道具 举报

板凳
ID:624769 发表于 2021-9-8 19:19 | 只看该作者
unsigned char idata Led_Matrix[16][10]=
{
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
};
你确定 你这满足  16x10 的数组么?

定外,你既然不重写,为什么不用 Code 用 idata? 160的 idata 用掉,你单片机可能 堆栈都不够用了……。
回复

使用道具 举报

地板
ID:964940 发表于 2021-9-8 22:29 | 只看该作者
188610329 发表于 2021-9-8 19:19
unsigned char idata Led_Matrix[16][10]=
{
         0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0 ...

搞好了,谢谢
回复

使用道具 举报

5#
ID:964940 发表于 2021-9-8 22:29 | 只看该作者
angmall 发表于 2021-9-8 18:36
又没有图,也没有描述清楚也不知道你的电路图是怎样的,
程序都是针对特定芯片编写的,

搞好了,谢谢
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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