找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1569|回复: 0
打印 上一主题 下一主题
收起左侧

stm32 1602液晶显示不能正常。求大佬帮忙 跪谢l

[复制链接]
跳转到指定楼层
楼主
ID:348627 发表于 2018-10-11 20:33 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
VSS 接GDN ,VDD 接5v  ,v0接GND  RS RW E接在stm32 5v兼容口  背光5v电压



#include "stm32f10x.h"
#include "delay.h"
#define Set_RS  GPIO_SetBits(GPIOB,GPIO_Pin_15)
#define Set_RW  GPIO_SetBits(GPIOB,GPIO_Pin_3)
#define Set_EN  GPIO_SetBits(GPIOB,GPIO_Pin_2)
#define CLR_RS  GPIO_ResetBits(GPIOB,GPIO_Pin_15)
#define CLR_RW  GPIO_ResetBits(GPIOB,GPIO_Pin_3)
#define CLR_EN  GPIO_ResetBits(GPIOB,GPIO_Pin_2)
GPIO_InitTypeDef GPIO_InitStructure;
unsigned char table[]="abcdefghijklmnop";
void Send_Com(unsigned char Send_Com)
{
CLR_RS;
GPIO_Write(GPIOA,(u16)Send_Com);
Delay_ms(5);
Set_EN;
Delay_ms(5);
CLR_EN;
}
void Send_Dat(unsigned char Send_Dat)
{
Set_RS;
GPIO_Write(GPIOA,Send_Dat);
Delay_ms(5);
Set_EN;
Delay_ms(5);
CLR_EN;
}
void init()
{
CLR_EN;
Send_Com(0x38);
Send_Com(0x0c);
Send_Com(0x06);
Send_Com(0x01);
}
void GPIO_Configuration(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB| RCC_APB2Periph_GPIOC, ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_15|GPIO_Pin_3|GPIO_Pin_2;
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_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(GPIOA,&GPIO_InitStructure);

}


int main(void)
{
unsigned char num;
GPIO_Configuration();
init();
Send_Com(0x80);
for(num=0;num<=15;num++)
{
Send_Dat(table[num]);
Delay_ms(5);
}
while(1);
}




分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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