標(biāo)題:
stm32f103實(shí)現(xiàn)lcd1602顯示Proteus仿真+代碼
[打印本頁(yè)]
作者:
liu_111011
時(shí)間:
2019-5-28 21:24
標(biāo)題:
stm32f103實(shí)現(xiàn)lcd1602顯示Proteus仿真+代碼
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)
0.png
(34.79 KB, 下載次數(shù): 83)
下載附件
2019-5-29 05:11 上傳
單片機(jī)源程序如下:
#include "bsp-lcd1602.h"
#include "param.h"
void LCD1602_GPIO_Config(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
GPIO_InitTypeDef LCD1602_InitTypeDef;
LCD1602_InitTypeDef.GPIO_Mode = GPIO_Mode_Out_PP;
LCD1602_InitTypeDef.GPIO_Speed = GPIO_Speed_10MHz;
LCD1602_InitTypeDef.GPIO_Pin = LCD1602_E | LCD1602_RS | LCD1602_RW ;
GPIO_Init(LCD1602_GPIO_PORT,&LCD1602_InitTypeDef);
LCD1602_InitTypeDef.GPIO_Mode = GPIO_Mode_Out_OD;
LCD1602_InitTypeDef.GPIO_Pin = DB0 | DB1 | DB2 |DB3 | DB4 | DB5|
DB6 | DB7 ; //設(shè)置為開(kāi)漏輸出
GPIO_Init(LCD1602_GPIO_PORT,&LCD1602_InitTypeDef);
}
void LCD1602_WaitReady(void) //檢測(cè)忙狀態(tài)
{
uint8_t sta;
GPIOB->ODR =0x00FF;
RSO(0);
RWO(1);
EO(1);
SysTick_Delay_Us(1);
do{
sta=GPIO_ReadInputDataBit(LCD1602_GPIO_PORT,GPIO_Pin_7);
EO(0);
}while(sta);
}
void LCD1602_WriteCmd(uint8_t cmd) //寫(xiě)指令
{
LCD1602_WaitReady();
RSO(0);
RWO(0);
EO(0);
SysTick_Delay_Us(1);
EO(1);
LCD1602_GPIO_PORT->ODR &= (cmd|0xFF00);
EO(0);
SysTick_Delay_Us(400);
}
void LCD1602_WriteDat(uint8_t dat) //寫(xiě)數(shù)據(jù)
{
LCD1602_WaitReady();
RSO(1);
RWO(0);
SysTick_Delay_Us(30);
EO(1);
LCD1602_GPIO_PORT->ODR &=(dat|0xFF00);
EO(0);
SysTick_Delay_Us(400);
}
void LCD1602_SetCursor(uint8_t x, uint8_t y)
{
uint8_t addr;
if (y == 0) //由輸入的屏幕坐標(biāo)計(jì)算顯示RAM的地址
addr = 0x00 + x; //第一行字符地址從0x00起始
else
addr = 0x40 + x; //第二行字符地址從0x40起始
LCD1602_WriteCmd(addr|0x80); //設(shè)置RAM地址
}
void LCD1602_ShowStr(uint8_t x, uint8_t y, uint8_t *str, uint8_t len)
{
LCD1602_SetCursor(x, y); //設(shè)置起始地址
while (len--) //連續(xù)寫(xiě)入len個(gè)字符數(shù)據(jù)
{
LCD1602_WriteDat(*str++);
}
}
復(fù)制代碼
所有資料51hei提供下載:
仿真+程序.7z
(228.69 KB, 下載次數(shù): 316)
2019-5-29 05:11 上傳
點(diǎn)擊文件名下載附件
下載積分: 黑幣 -5
作者:
萬(wàn)古琴
時(shí)間:
2019-8-24 20:34
終于找到STM32相關(guān)仿真電路,謝謝啊
作者:
cookidog
時(shí)間:
2020-10-18 23:31
非常好,用systick控制的lcd1602字符顯示
歡迎光臨 (http://www.torrancerestoration.com/bbs/)
Powered by Discuz! X3.1