久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 1387|回復(fù): 4
打印 上一主題 下一主題
收起左側(cè)

AT89C51單片機(jī)驅(qū)動st7920的屏幕

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:406814 發(fā)表于 2024-6-5 00:25 | 只看該作者 回帖獎勵 |倒序?yàn)g覽 |閱讀模式
各位大佬,這個是我的st7920驅(qū)動文件,上面紅色字體部分是我連接的對應(yīng)管腳,但是無法驅(qū)動。
哪位可以幫忙看一下呢?

lcd12864.h 文件;

#ifndef __LCD12864_H__
#define __LCD12864_H__

#include <reg52.h>
#include <intrins.h>
sbit RS = P0 ^ 0;
sbit RW = P0 ^ 1;
sbit EN = P0 ^ 2;
sbit PSB = P3 ^ 0;
sbit RST = P3 ^ 1;
#define _NOP() _nop_()
/* 12864 ?????? */
#define RS_CLR RS = 0 /* RS ?? */
#define RS_SET RS = 1 /* RS ?? */
#define RW_CLR RW = 0 /* RW ?? */
#define RW_SET RW = 1 /* RW ?? */
#define EN_CLR EN = 0 /* E ?? */
#define EN_SET EN = 1 /* E ?? */
#define PSB_CLR PSB = 0 /* PSB ??,???? */
#define PSB_SET PSB = 1 /* PSB ??,???? */
#define RST_CLR RST = 0 /* RST ?? , ??? */
#define RST_SET RST = 1 /* RST ?? */
/* 12864 ?????? */
#define DataPort P2 /*  ??? */
#define LcdData P2
void Delay_1ms( void );
void Delay_Nms( unsigned int n );
void LCD_write_com( unsigned char cmd );
void LCD_write_data( unsigned char dat );
void Ini_Lcd( void );
void Lcd_WriteStr( unsigned char x, unsigned char y, unsigned char *Str );
unsigned char Lcd_CheckBusy( void );
unsigned char Lcd_ReadData( void );

#endif


復(fù)制代碼

lcd12864.c 文件;

#include "LCD12864.h"

void delay_us( unsigned int t ) /* @11.0592MHz */
{
        while ( t-- ) {
                _nop_();
                _nop_();
                _nop_();
        }
}
void delay_ms( unsigned int t ) /* @11.0592MHz */
{
        unsigned char i, j;
        while ( t-- ) {
                _nop_();
                _nop_();
                _nop_();
                i = 11;
                j = 190;
                do {
                        while ( --j )
                                ;
                } while ( --i );
        }
}
void Delay_1ms( void )
{
        delay_ms( 1 );
}
/*
* ***********************************************************************
*  ?????????
* ***********************************************************************
*/
void LCD_write_com( unsigned char cmd )
{
        while ( Lcd_CheckBusy() ) {}


        RS_CLR;
        RW_CLR;
        EN_SET;
        DataPort = cmd;
        EN_CLR;
}
/*
* ***********************************************************************
*  ?????????
* ***********************************************************************
*/
void LCD_write_data( unsigned char dat )
{
        while ( Lcd_CheckBusy() )
                ;
        RS_SET;
        RW_CLR;
        EN_SET;
        DataPort = dat;
        /* delay_us( 1 ); */
        EN_CLR;
}
/*
* *************************************************************************
* ??? IO ????
* *************************************************************************
*/
void Port_init_12864( void )
{
        delay_ms( 50 );
        PSB_SET; /*  ?????? */
        RST_CLR;
        delay_ms( 100 );
        RST_SET;
}
/*******************************************
*  ????: Ini_Lcd
*  ? ?:???????
*  ? ?:?
*  ??? :?
********************************************/
void Ini_Lcd( void )
{
        Port_init_12864(); /*  ??????????? */
        LCD_write_com( 0x30 ); /*  ????? */
        Delay_1ms();
        LCD_write_com( 0x02 ); /*  ???? */
        Delay_1ms();
        LCD_write_com( 0x0c ); /*  ?????? , ???? */
        Delay_1ms();
        LCD_write_com( 0x01 ); /*  ???? */
        Delay_1ms();
        LCD_write_com( 0x06 ); /*  ???? */
        Delay_1ms();
        LCD_write_com( 0x80 ); /*  ????????? */
}
/*
* ***********************************************************************
*  ??????????????
* ***********************************************************************
*/
void Lcd_WriteStr( unsigned char x, unsigned char y, unsigned char *Str )
{
        if ( (y > 3) || (x > 7) )
                return; /*  ???????? */
        if ( y == 0 ) {
                LCD_write_com( 0x80 + x ); /*  ????? */
        }
        if ( y == 1 ) {
                LCD_write_com( 0x90 + x ); /*  ????? */
        }
        if ( y == 2 ) {
                LCD_write_com( 0x88 + x ); /*  ????? */
        }
        if ( y == 3 ) {
                LCD_write_com( 0x98 + x ); /*  ????? */
        }
        delay_us( 1 );
        while ( *Str > 0 ) {
                LCD_write_data( *Str );
                Str++;
                delay_us( 1 );
        }
}
unsigned char Lcd_CheckBusy( void )
{
        unsigned char Busy;
        RS_CLR;
        RW_SET;
        EN_SET;
        delay_us( 5 );
        Busy = LcdData & 0x80;
        EN_CLR;
        return(Busy);
}
/***********************************
*  ? LCD ?????
************************************/
unsigned char Lcd_ReadData( void )
{
        unsigned char Temp;
        while ( Lcd_CheckBusy() )
                ;
        P0 = 0XFF;
        RS_SET;
        RW_SET;
        EN_SET;
        delay_us( 10 );
        Temp = LcdData;
        EN_CLR;
        return(Temp);
}



main.c 文件
#include "reg52.h"
#include <intrins.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "LCD12864.h"
void main( void )
{
    Ini_Lcd();
    Lcd_WriteStr(0,0,"12345678");
    while ( 1 )
    {
    }
}


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:35873 發(fā)表于 2024-6-5 03:14 | 只看該作者


看這個有沒有用
/*
**SMG12864ZK并行接口參考程序
**電話:
**最后修改 :  2005年8月25日
*/
#include <reg51.h>
#include <intrins.h>
sbit RS = P3^0;
sbit RW = P3^3;
sbit E = P3^4;
sbit PSB = P3^1;          //串并口選擇
sbit RES = P3^5;

#define FIRST_ADDR 0       //定義字符/漢字顯示起始位置
//延時子程序
void delay(unsigned int t)
{  unsigned int i,j;
   for(i=0;i<t;i++)
      for(j=0;j<10;j++)
         ;
}
//測忙
void chk_busy()
{  RS=0;
   RW=1;
   E=1;
   while((P1&0x80)==0x80);
   E=0;
}
//讀數(shù)據(jù)
unsigned char lcdrd()
{  unsigned char i;
   P3=0xFB;
   _nop_();
   E=1;
   delay(5);
   i=P1;
   _nop_();
   E=0;
   return i;
}
//寫數(shù)據(jù)
void lcdwd(unsigned char dispdata)
{  chk_busy();
   _nop_();
   RS=1;
   RW=0;
   E=1;
   P1=dispdata;
   delay(5);
   _nop_();
   E=0;
   _nop_();
   P1=0xff;
}
//寫指令代碼
void lcdwc(unsigned char cmdcode)
{  chk_busy();
   _nop_();
   RS=0;
   RW=0;
   E=1;
   P1=cmdcode;
   delay(5);
   _nop_();
   E=0;
   _nop_();
   P1=0xff;
}
//初始化
void lcdreset()
{  delay(2000);
   lcdwc(0x30);       //選擇基本指令集
   lcdwc(0x30);       //選擇8bit數(shù)據(jù)流
   delay(5);
   lcdwc(0x0c);       //開顯示(無游標(biāo)、不反白)
   delay(5);
   lcdwc(0x01);       //清除顯示,并且設(shè)定地址指針為00H
   delay(5);
   lcdwc(0x06);       //指定在資料的讀取及寫入時,設(shè)定游標(biāo)的移動方向及指定顯示的移位
}
void hzkdis(unsigned char code *s)
{  while(*s>0)
   {  lcdwd(*s);
      s++;
      delay(500);
   }
}
void hzklib()
{  lcdwc(0x80+FIRST_ADDR);
   hzkdis("少小離家老大回,");
   lcdwc(0x90+FIRST_ADDR);
   hzkdis("鄉(xiāng)音無改鬢毛衰。");
   lcdwc(0x88+FIRST_ADDR);
   hzkdis("兒童相見不相識,");
   lcdwc(0x98+FIRST_ADDR);
   hzkdis("笑問客從何處來。");
}
//整屏顯示
//當(dāng)ii=0時顯示上面128×32
//當(dāng)ii=8時顯示下面128×32
void lcdfill(unsigned char disdata)
{  unsigned char x,y,ii;
   for(ii=0;ii<9;ii+=8)
      for(y=0;y<0x20;y++)
         for(x=0;x<8;x++)
         {  lcdwc(0x36);
            lcdwc(y+0x80);        //行地址
            lcdwc(x+0x80+ii);     //列地址
            lcdwc(0x30);
            lcdwd(disdata);
            lcdwd(disdata);
         }
}
main()
{  RES=0;
   _nop_();
   RES=1;
   while(1)
   {  PSB=1;
      RW=0;
      lcdreset();       //初始化LCD屏
      lcdwc(0x01);
      delay(1000);
      lcdfill(0xff);
      delay(6000);
      lcdfill(0);
      lcdwc(0x01);
      delay(1000);
      hzklib();
      delay(4000);
   }
}

回復(fù)

使用道具 舉報

板凳
ID:366877 發(fā)表于 2024-6-5 06:49 | 只看該作者
軟件要和硬件配合工作的,P0口有上拉電阻嗎?
回復(fù)

使用道具 舉報

地板
ID:406814 發(fā)表于 2024-6-6 01:14 | 只看該作者
jialishoushi 發(fā)表于 2024-6-5 03:14
看這個有沒有用
/*
**SMG12864ZK并行接口參考程序

哥,你這代碼移動起來有點(diǎn)費(fèi)勁吶。。 目測應(yīng)該是錯的。不過改天我實(shí)際測一下吧。我現(xiàn)在先搞我自己的。
回復(fù)

使用道具 舉報

5#
ID:406814 發(fā)表于 2024-6-6 01:15 | 只看該作者
wdgao 發(fā)表于 2024-6-5 06:49
軟件要和硬件配合工作的,P0口有上拉電阻嗎?

大佬,果真是這樣的哦,起初我也懷疑過這里,不過我沒有試過。你說了之后我就去試了,果然是這里。目前已經(jīng)可以了。感謝啊。
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表
主站蜘蛛池模板: 国产一级免费视频 | 九九九久久国产免费 | 精品国产黄a∨片高清在线 www.一级片 国产欧美日韩综合精品一区二区 | 国产精品国产馆在线真实露脸 | 色视频成人在线观看免 | 成人99| 综合婷婷 | 中文字幕成人在线 | 草久在线| 日韩欧美在线观看视频 | 亚洲精品视频观看 | 九九综合 | 中文字幕人成乱码在线观看 | www网站在线观看 | 亚洲视频精品 | 99久久国产综合精品麻豆 | 二区在线观看 | 91精品久久久久久久久久入口 | 福利视频一区二区 | 国产精品成人一区二区三区吃奶 | 国产精品欧美一区二区三区不卡 | 午夜性色a√在线视频观看9 | 国产特级毛片 | 日韩国产中文字幕 | 欧美日韩视频在线 | 五月激情六月婷婷 | 2021天天躁夜夜看 | 久草在线 | 日韩av成人在线观看 | 国产精品久久久久久久久久 | 日韩欧美大片在线观看 | 91在线电影 | 国产精品一区视频 | 亚洲精品一区二区 | 国产探花在线精品一区二区 | 逼逼网| 国产一区二区三区四区三区四 | 一区二区三区免费看 | 久久久久国色av免费观看性色 | 美国av毛片 | 一级做a爰片久久毛片 |