There is currently 1 post.
Font size: Small - 100% (Default)  Content converter: No conversion
 
Clicks Replies
1091 0
【解决办法】51单片机程序卡在检查12864液晶忙信号的while循环里
巨大八爪鱼
武林盟主 二十一级
Reply
Floor 1 Posted at: 7/8/16 23:00
拔掉开发板上P0口(液晶数据端口)的LED灯跳线即可。
因为如果P0口上同时接了LED灯的话,单片机无法正常读取液晶通过P0口发来的数据。
【测试程序】
#include <reg52.h>

sbit LED1 = P1^0;
sbit LED2 = P1^1;
sbit LED3 = P1^2;

sbit RS = P2^0;
sbit RW = P2^1;
sbit E = P2^2;
sbit PSB = P2^3;
sbit RESET = P2^5;
sbit BF = P0^7;

void delay(unsigned int n)
{
    unsigned char i;
    while (n--)
        for (i = 0; i < 115; i++);
}

int main(void)
{
    delay(40);
   
    LED1 = 0; // LED1表示正在检查忙型信号
    LED2 = 1; // LED2表示程序因忙信号阻塞
    LED3 = 1; // LED3亮表示程序成功通过忙信号检查
   
    P0 = 0xff;
    RS = 0;
    RW = 1;
    E = 1;
    while (BF)
        LED2 = 0;
    E = 0;
    LED2 = 1;
    LED1 = 1;
    LED3 = 0;
   
    // 最后只有LED3亮,表明程序通过了忙信号检查
    // 如果最后是LED1和LED2都亮,则表明程序卡在了忙信号检查部分
   
    while (1);
}
Reply the post
Content:
User: You are currently anonymous.
Captcha:
Unclear? Try another one.
(Shortcut key: Ctrl+Enter)
Post Information
Clicks: 1091 Replies: 0
Author: 巨大八爪鱼
Last reply: 巨大八爪鱼
Last reply time: 7/8/16 23:00
Announcements