OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 2489|回复: 0

DB7位只要为1,判忙函数就不跳出循环,且液晶只亮不显示,不知道自己的时序对不对

[复制链接]

2

主题

3

帖子

0

精华

新手入门

积分
15
金钱
15
注册时间
2018-10-10
在线时间
4 小时
发表于 2018-10-10 11:32:30 | 显示全部楼层 |阅读模式
液晶型号:液晶是LM6800,驱动是S6B0108,
代码:
1.main.c函数
int main(void)
{
        SystemInit();                                       
        LCD_GPIO_Configuration();
        LCD6800_Init();
        delay_ms(5);
        Display_String(0,0,0,(const uint8_t *)name);//这个函数对const数组的使用也不确定对不对
  while(1)
        {               
  }
}

2.LCD6800.c函数
/********************************************************************************
描述:LCD256*64(S6B0108)
*             PE3 - RS   
*             PE4 - R/W   
*             PE2 - E        
*            PD0-PD7 - DB0-DB7   
*             PC12 - CSA  
                PC9 - CSB   
                PC8 - CSC   
*             PB5 - /RST  
*           -----------------  
**********************************************************************************/


/********************************************************************************

* LCD命令控制:
                              复位:/RST=0    正常:/RST=1
                              片选:CSC,CSB,CSA
                                        000: 允许访问LCD的左64列
                                        001: 允许访问LCD的左中64列
                                        010: 允许访问LCD的右中64列
                                        011: 允许访问LCD的右64列

                          写命令:E=1-0;R/W=0;RS=0
                          写数据:E=1-0;R/W=0;RS=1
                         读命令:E=1;R/W=1;RS=0
                         读数据:E=1;R/W=1;RS=1

**********************************************************************************/

void LCD_GPIO_Configuration(void)
{
        GPIO_InitTypeDef   GPIO_InitStructure;
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC |
                               RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE);
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;//¸′λòy½Å
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOB, &GPIO_InitStructure);
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_12;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOC, &GPIO_InitStructure);
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 |
                                      GPIO_Pin_4| GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOD, &GPIO_InitStructure);
       
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
        GPIO_Init(GPIOE, &GPIO_InitStructure);
       
}

void LCD6800_Init(void)
{
        LCD_RST_0;
        delay_ms(5);
        LCD_RST_1;
        Select_Screen(0);//选择全屏
        Write_Cmd(LCD_OFF);
        Write_Cmd(LCD_ON);
        LCD_Clear(0);
        Write_Cmd(LCD_StartLine);//LCD_StartLine为0xc0,到这判忙函数一直处于循环出不来
}

void Display_Screen1(void)//选择左64列
{
        LCD_CSC_0;
        LCD_CSB_0;
        LCD_CSA_0;
}

void Display_Screen2(void)//左中64列
{
        LCD_CSC_0;
        LCD_CSB_0;
        LCD_CSA_1;
}

void Display_Screen3(void)//右中64列
{
        LCD_CSC_0;
        LCD_CSB_1;
        LCD_CSA_0;
}

void Display_Screen4(void)//右64列
{
        LCD_CSC_0;
        LCD_CSB_1;
        LCD_CSA_1;
}


void Select_Screen(uint8_t screen)
{
        switch(screen)
        {
                case 0:
                    Display_Screen1();
                    Display_Screen2();
                    Display_Screen3();
                    Display_Screen4();
                  break;
                case 1:
                                Display_Screen1();
                  break;
                case 2:
                                Display_Screen2();
                  break;
                case 3:
                                Display_Screen3();
                  break;
                case 4:
                                Display_Screen4();
                  break;
                default:
                        break;                       
  }
       
       
}

uint8_t LCD_busy(void)
{
        uint8_t busy_flag;
        LCD_RS_0;
        LCD_RW_1;
        LCD_E_1;
        delay_ms(5);
        busy_flag=Text_Busy;//Text_Busy是DB7口检测的数据
        LCD_E_0;       
        return busy_flag;
}

void Write_Cmd(uint8_t cmd)
{
        while(LCD_busy());//只要DB7位为1,程序就一直处于循环出不来
        LCD_RS_0;
        LCD_RW_0;
        Data_Out(cmd);
        delay_ms(1);
        LCD_E_1;
        delay_ms(1);
        LCD_E_0;       
}


void Write_Data(uint8_t data)
{
        //while(LCD_busy());
        LCD_RS_1;
        LCD_RW_0;
        Data_Out(data);
        delay_ms(1);
        LCD_E_1;
        delay_ms(1);
        LCD_E_0;       
}

void LCD_Clear(uint8_t screen)
{
        uint16_t i,j;
        Select_Screen(screen);
        for(i=0;i<8;i++)
        {
                Write_Cmd(LCD_Page+i);
          Write_Cmd(LCD_column);       
                for(j=0;j<64;j++)
                {
                        Write_Data(0x00);
    }
  }
}

void Display_String(uint8_t screen,uint8_t page,uint8_t column,const uint8_t *dat)
{
        Select_Screen(screen);
        if(column>=64)
  {
      column=column-1;
  }
        Write_Cmd(LCD_column|column);
        delay_ms(1);
        Write_Cmd(LCD_Page|page);
        Write_Data(*dat);
        dat++;
}


3.LCD6800.h函数
#ifndef _LCD6800_H_
#define _LCD6800_H_

#include "stm32f10x.h"
#include "LED.h"

#define   RST       GPIOB,GPIO_Pin_5
#define   RW        GPIOE,GPIO_Pin_4
#define   RS        GPIOE,GPIO_Pin_3
#define   E         GPIOE,GPIO_Pin_2

//&#198;&#172;&#209;&#161;&#207;&#223;
#define   CSA       GPIOC,GPIO_Pin_12
#define   CSB       GPIOC,GPIO_Pin_9
#define   CSC       GPIOC,GPIO_Pin_8

//êy&#190;Y&#207;&#223;
#define   LCDDB0    GPIOD,GPIO_Pin_0
#define   LCDDB1    GPIOD,GPIO_Pin_1
#define   LCDDB2    GPIOD,GPIO_Pin_2
#define   LCDDB3    GPIOD,GPIO_Pin_3
#define   LCDDB4    GPIOD,GPIO_Pin_4
#define   LCDDB5    GPIOD,GPIO_Pin_5
#define   LCDDB6    GPIOD,GPIO_Pin_6
#define   LCDDB7    GPIOD,GPIO_Pin_7


#define LCD_DataPort   GPIOD         
#define Data_Out(x)    LCD_DataPort->ODR=(LCD_DataPort->ODR&0xff00)|(x&0x00ff);
#define Text_Busy      GPIO_ReadInputDataBit(GPIOD ,GPIO_Pin_7);

#define  LCD_column        0x40  
#define  LCD_Page          0xb8  
#define  LCD_ON            0x3f
#define  LCD_OFF           0x3e  
#define  LCD_StartLine     0xc0  


#define LCD_RST_1   GPIO_SetBits(GPIOB,GPIO_Pin_5);      //RST = 1   
#define LCD_RST_0   GPIO_ResetBits(GPIOB,GPIO_Pin_5);    //RST = 0

#define LCD_RS_1    GPIO_SetBits(GPIOE,GPIO_Pin_3);       //RS=1   
#define LCD_RS_0    GPIO_ResetBits(GPIOE,GPIO_Pin_3);     //RS=0

#define LCD_RW_1    GPIO_SetBits(GPIOE,GPIO_Pin_4);       //R/W=1   
#define LCD_RW_0    GPIO_ResetBits(GPIOE,GPIO_Pin_4);    //R/W = 0

#define LCD_E_1     GPIO_SetBits(GPIOE,GPIO_Pin_2);      //E = 1   
#define LCD_E_0     GPIO_ResetBits(GPIOE,GPIO_Pin_2);    //E = 0

#define LCD_CSC_1   GPIO_SetBits(GPIOC,GPIO_Pin_8);      //CSC = 1   
#define LCD_CSC_0   GPIO_ResetBits(GPIOC,GPIO_Pin_8);    //CSC = 0
#define LCD_CSB_1   GPIO_SetBits(GPIOC,GPIO_Pin_9);      //CSB = 1   
#define LCD_CSB_0   GPIO_ResetBits(GPIOC,GPIO_Pin_9);    //CSB = 0
#define LCD_CSA_1   GPIO_SetBits(GPIOC,GPIO_Pin_12);     //CSA = 1   
#define LCD_CSA_0   GPIO_ResetBits(GPIOC,GPIO_Pin_12);   //CSA = 0



void LCD6800_Init(void);
void LCD_GPIO_Configuration(void);
void Display_Screen1(void);
void Display_Screen2(void);
void Display_Screen3(void);
void Display_Screen4(void);
void Select_Screen(uint8_t screen);
uint8_t LCD_busy(void);
void Write_Cmd(uint8_t cmd);
void Write_Data(uint8_t data);
void LCD_Clear(uint8_t screen);
void delay_ms(uint16_t nms);
void delay_us(uint32_t nus);
void Display_String(uint8_t screen,uint8_t page,uint8_t column,const uint8_t *dat);

#endif

4.字库函数
#include "Tab.h"
const uint8_t name[]=
{
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,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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B5,0xAE,0xAD,0x7D,0xFB,0xB0,0x6B,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFD,0xD6,0xB6,0xB6,0xB5,0xAE,0xAB,
0x7D,0xDB,0xB7,0x6B,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0x39,0x8F,
0x76,0xC5,0xA6,0x87,0x06,0x38,0x6F,0xB7,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xBF,0x7F,0xB7,0xFF,0x79,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xBE,0xFF,0xCF,0xFF,0x87,0xFF,0xFF,0xFF,0xFF
};


捕获.PNG

LM6800.pdf

184.35 KB, 下载次数: 6

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-6-21 02:22

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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