欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3345|回復: 13
收起左側

想用8255實現LCD1602的顯示,但是顯示不了。求助大家!

[復制鏈接]
ID:744425 發表于 2020-6-14 18:36 | 顯示全部樓層 |閱讀模式
對1602的設置如下:

#include <REG51.h>
#include <ABSACC.h>
#define uchar unsigned char
#define uint unsigned int
#define F8255S XBYTE[0xdfff]
#define PA XBYTE[0xdffc]
#define PB XBYTE[0xdffd]
sbit RS=P2^0;
sbit RW=P2^1;
sbit EN=P2^2;
void write_com(uchar com)
{
  PA=com;
  RS=0;RW=0;EN=1;
  delay(10);
  EN=0;
}

void write_dat(uchar dat)
{
  PA=dat;  
  RS=1;RW=0;EN=1;
  delay(10);  
  EN=0;
}

void init_LM1602()
{
  write_com(0x01);
  write_com(0x38);
  write_com(0x0c);
  write_com(0x06);
}
仿真圖:

capture_20200614183423585.jpg
回復

使用道具 舉報

ID:24758 發表于 2020-6-15 09:11 | 顯示全部樓層
是不是因為沒有設置8255的工作方式啊?
回復

使用道具 舉報

ID:744425 發表于 2020-6-15 10:05 | 顯示全部樓層
epson009 發表于 2020-6-15 09:11
是不是因為沒有設置8255的工作方式啊?

我設置了F8255S=0x80,主要是想PA口負責控制LCD顯示,要是能用PB口或者PC口控制RS、RW、EN就好了,可是不會
回復

使用道具 舉報

ID:744425 發表于 2020-6-15 10:08 | 顯示全部樓層
epson009 發表于 2020-6-15 09:11
是不是因為沒有設置8255的工作方式啊?

仿真和代碼在下面,您能幫我看看嗎?
回復

使用道具 舉報

ID:744425 發表于 2020-6-15 10:09 | 顯示全部樓層
8255LCD.rar (68.63 KB, 下載次數: 33)
回復

使用道具 舉報

ID:24758 發表于 2020-6-15 11:48 | 顯示全部樓層
我看了下你的電路,里面的373鎖存器LE 端不能一直接地,你把它和單片機的ALE接到一塊,就可以了。

1.png

評分

參與人數 1黑幣 +20 收起 理由
admin + 20 回帖助人的獎勵!

查看全部評分

回復

使用道具 舉報

ID:24758 發表于 2020-6-15 11:49 | 顯示全部樓層
之前的圖里面373的LE沒問題啊~~
回復

使用道具 舉報

ID:744425 發表于 2020-6-15 18:26 | 顯示全部樓層
epson009 發表于 2020-6-15 11:49
之前的圖里面373的LE沒問題啊~~

抱歉抱歉,可能是因為我在兩張圖上畫,導致圖片里的和文件里的不太一樣了,改了LE之后能顯示出來了。但是我剛剛演示的時候發現,好像66度的時候,后面那個6顯示不出來,還有一些數字顯示也有問題。您知道這是為什么嗎?
回復

使用道具 舉報

ID:24758 發表于 2020-6-16 06:18 | 顯示全部樓層
是不是電路設計上的問題啊?看了半天也沒看出來
回復

使用道具 舉報

ID:744425 發表于 2020-6-16 11:38 | 顯示全部樓層
epson009 發表于 2020-6-16 06:18
是不是電路設計上的問題啊?看了半天也沒看出來

真的好迷啊,我也沒看出啥問題
回復

使用道具 舉報

ID:744425 發表于 2020-6-16 19:50 | 顯示全部樓層
epson009 發表于 2020-6-15 11:48
我看了下你的電路,里面的373鎖存器LE 端不能一直接地,你把它和單片機的ALE接到一塊,就可以了。

咦,是的啊,我把373的LE和單片機的ALE連在一起了,但是連完之后有的數字還是顯示不全,只顯示了一部分。
回復

使用道具 舉報

ID:683360 發表于 2020-9-26 23:03 | 顯示全部樓層
程序沒有寫完整啊
回復

使用道具 舉報

ID:106821 發表于 2020-9-29 15:02 | 顯示全部樓層
373鎖存器LE 端應該和單片機的ALE同名連接
回復

使用道具 舉報

ID:155507 發表于 2020-9-29 20:34 | 顯示全部樓層
我給你來個試試
8255LCD1602.jpg



  1. #include < reg51.h >

  2. char xdata PORTA _at_ 0x4000; //by making PORTA with address 4000H we are selecting Port A of the 8255
  3. // and the CS low (select the 8255)
  4. char xdata PORTB _at_ 0x4001; //by making PORTB with address 4001H we are selecting Port B of the 8255
  5. // and the CS low (select the 8255)

  6. void send_command(unsigned char i);
  7. void send_data(unsigned char i);
  8. void delay();

  9. void main(void)
  10. {
  11.         unsigned int i=0;
  12.         unsigned char line_1[] = "51HEI Hello ";
  13.         unsigned char line_2[] = "MICROCONTROLLER";

  14.         send_command(0x38); // Initialize LCD in 16x2 matrix mode
  15.         send_command(0x0E); // Display ON and cursor ON
  16.         send_command(0x01); // Clear the LCD
  17.         send_command(0x83); // Select first line and position of the cursor to 83H + position

  18.         // Display the dat on LCD's first line
  19.         for (i = 0; i < 11; i++)
  20.         {
  21.                 send_data(line_1[i]);
  22.         }

  23.         send_command(0xC0); // Select the second line

  24.         // Display the dat on LCD's second line
  25.         for (i = 0; i < 16; i++)
  26.         {
  27.                 send_data(line_2[i]);
  28.         }

  29.         while(1); //Loop forever to display the dat until the power is switched OFF
  30. }

  31. //Function to send command
  32. void send_command(unsigned char i)
  33. {
  34.         PORTA = i; //put data into 4000H

  35.         // Port B is connected to the command pins i.e. RS, R/W, and E
  36.         PORTB = 0x04; //4001H = 04H (00000100B) implies E = 1, RW = 0 (Write to LCD), RS = 0 (Command to be wriiten)
  37.         delay();

  38.         PORTB = 0x00; //4001H = 00H (00000000B) implies E = 0 (High to low pulse), RW = 0 (Write to LCD), RS = 0 (Command to be wriiten)
  39.         delay();
  40.         return;
  41. }

  42. //Function to send dat
  43. void send_data (unsigned char i)
  44. {
  45.         PORTA = i; //put data into 4000H

  46.         // Port B is connected to the command pins i.e. RS, R/W, and E
  47.         PORTB = 0x05; // 4001H = 05H (00000101B) implies E = 1, RW = 0 (Write to LCD), RS = 1 (Data to be wriiten to LCD)
  48.         delay();

  49.         PORTB = 0x01; // 4001H = 01H (0000 0001B) implies E = 0 (High to low pulse), RW = 0 (Write to LCD), RS = 1 (Data to be wriiten to LCD)
  50.         delay();
  51.         return;
  52. }

  53. // Function to generate delay
  54. void delay()
  55. {
  56.         unsigned int i =0;
  57.         for (i = 0; i < 100; i++);
  58. }


復制代碼




回復

使用道具 舉報

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

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表