• 大小: 2.51MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-08-10
  • 语言: 其他
  • 标签: cc  lcd1602  stm32  

资源简介

基于STM32的LCD1602显示,neng能正常运行,完美显示1602

资源截图

代码片段和文件信息

#include “lcd.h“



void LCD_GPIO_Config(void)
{
GPIO_InitTypeDef  GPIO_InitStruct;
RCC_APB2PeriphClockCmd(LCD_RS_CLK|LCD_DB0_CLK ENABLE);  //使能引脚时钟
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin=LCD_RS_PIN|LCD_RW_PIN|LCD_E_PIN;
GPIO_InitStruct.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(LCD_RS_PORT&GPIO_InitStruct);

GPIO_InitStruct.GPIO_Pin=LCD_DB0_PIN|LCD_DB1_PIN|LCD_DB2_PIN|LCD_DB3_PIN|LCD_DB4_PIN|LCD_DB5_PIN|LCD_DB6_PIN|LCD_DB7_PIN;
GPIO_Init(LCD_DB0_PORT&GPIO_InitStruct);
}

void delay(u32 i)
{
i=i+10;
while(i--);
}


void Busy_Wait(void)
{
GPIO_InitTypeDef  GPIO_InitStruct;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_InitStruct.GPIO_Pin=LCD_DB0_PIN|LCD_DB1_PIN|LCD_DB2_PIN|LCD_DB3_PIN|LCD_DB4_PIN|LCD_DB5_PIN|LCD_DB6_PIN|LCD_DB7_PIN;
GPIO_Init(LCD_DB0_PORT&GPIO_InitStruct);

RS_L;
RW_H;
E_L;
delay(5);
E_H;
while(GPIO_ReadInputDataBit(LCD_DB0_PORTLCD_DB7_PIN)==1);
E_L;
GPIO_InitStruct.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStruct.GPIO_Pin=LCD_DB0_PIN|LCD_DB1_PIN|LCD_DB2_PIN|LCD_DB3_PIN|LCD_DB4_PIN|LCD_DB5_PIN|LCD_DB6_PIN|LCD_DB7_PIN;
GPIO_Init(LCD_DB0_PORT&GPIO_InitStruct);
}

void LCD_WRITE_CMD(u8 cmd)
{
Busy_Wait();
E_L;
RS_L;
RW_L;
E_H;
GPIO_Write(LCD_DB0_PORT cmd);
E_L;
delay(5);
E_H;
RW_H;
}

void LCD_WRITE_DAT(u8 dat)
{
Busy_Wait();
E_L;
RS_H;
RW_L;
E_H;
GPIO_Write(LCD_DB0_PORT dat);
E_L;
delay(5);
E_H;
RW_H;
}




void LCD_INIT(void)
{
LCD_GPIO_Config();
E_L;
RS_L;
RW_L;
delay(5);
LCD_WRITE_CMD(0x38);
LCD_WRITE_CMD(0x0c);
LCD_WRITE_CMD(0x06);
LCD_WRITE_CMD(0x01);
}












 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-02-25 23:25  LCD_1602\
     目录           0  2016-02-26 00:22  LCD_1602\BSP\
     文件        1707  2016-02-26 00:22  LCD_1602\BSP\lcd.c
     文件        1718  2016-02-25 23:58  LCD_1602\BSP\lcd.h
     文件         359  2016-02-25 19:54  LCD_1602\BSP\led.c
     文件         140  2016-02-25 19:41  LCD_1602\BSP\led.h
     文件        2049  2016-02-25 23:25  LCD_1602\BSP\uart.c
     文件         182  2016-02-25 20:31  LCD_1602\BSP\uart.h
     目录           0  2016-02-25 23:25  LCD_1602\CORE&START\
     目录           0  2016-02-25 23:25  LCD_1602\CORE&START\arm\
     文件       15766  2011-03-10 10:52  LCD_1602\CORE&START\arm\startup_stm32f10x_cl.s
     文件       15503  2011-03-10 10:52  LCD_1602\CORE&START\arm\startup_stm32f10x_hd.s
     文件       15692  2011-03-10 10:52  LCD_1602\CORE&START\arm\startup_stm32f10x_hd_vl.s
     文件       12376  2011-03-10 10:52  LCD_1602\CORE&START\arm\startup_stm32f10x_ld.s
     文件       13656  2011-03-10 10:52  LCD_1602\CORE&START\arm\startup_stm32f10x_ld_vl.s
     文件       12765  2011-03-10 10:52  LCD_1602\CORE&START\arm\startup_stm32f10x_md.s
     文件       14073  2011-03-10 10:51  LCD_1602\CORE&START\arm\startup_stm32f10x_md_vl.s
     文件       15955  2011-03-10 10:51  LCD_1602\CORE&START\arm\startup_stm32f10x_xl.s
     文件       17273  2010-06-07 10:25  LCD_1602\CORE&START\core_cm3.c
     文件       85714  2011-02-09 14:59  LCD_1602\CORE&START\core_cm3.h
     文件      633941  2011-03-10 10:51  LCD_1602\CORE&START\stm32f10x.h
     文件        3259  2011-04-04 19:03  LCD_1602\CORE&START\stm32f10x_conf.h
     文件        4669  2016-02-25 20:34  LCD_1602\CORE&START\stm32f10x_it.c
     文件        2086  2011-04-04 19:03  LCD_1602\CORE&START\stm32f10x_it.h
     文件       36557  2011-04-04 19:03  LCD_1602\CORE&START\system_stm32f10x.c
     文件        2085  2011-03-10 10:51  LCD_1602\CORE&START\system_stm32f10x.h
     目录           0  2016-02-25 23:25  LCD_1602\LIB\
     目录           0  2016-02-25 23:25  LCD_1602\LIB\inc\
     文件        8982  2011-03-10 10:47  LCD_1602\LIB\inc\misc.h
     文件       21690  2011-03-10 10:47  LCD_1602\LIB\inc\stm32f10x_adc.h
     文件        7555  2011-03-10 10:47  LCD_1602\LIB\inc\stm32f10x_bkp.h
............此处省略101个文件信息

评论

共有 条评论