欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
仿真LCD1602不亮
[打印本頁]
作者:
哈哈125
時間:
2025-4-13 23:45
標題:
仿真LCD1602不亮
屏幕截圖 2025-04-12 202159.png
(43.28 KB, 下載次數: 0)
下載附件
2025-4-13 23:42 上傳
求問為什么這個仿真lcd1602 不亮啊而且高低電平也沒有顯示
#include "lcd1602.h"
#include "stm32f1xx_hal.h"
#include "delay.h"
static void LCD_Enable(void);
static void LCD_Write8Bits(uint8_t data)
{
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D0_PIN, (data & 0x01) ? GPIO_PIN_SET : GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D1_PIN, (data & 0x02) ? GPIO_PIN_SET : GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D2_PIN, (data & 0x04) ? GPIO_PIN_SET : GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D3_PIN, (data & 0x08) ? GPIO_PIN_SET : GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D4_PIN, (data & 0x10) ? GPIO_PIN_SET : GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D5_PIN, (data & 0x20) ? GPIO_PIN_SET : GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D6_PIN, (data & 0x40) ? GPIO_PIN_SET : GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_DATA_PORT, LCD_D7_PIN, (data & 0x80) ? GPIO_PIN_SET : GPIO_PIN_RESET);
LCD_Enable();
}
void LCD_Init(void) {
HAL_Delay(50);
}
void LCD_SendCommand(uint8_t cmd) {
HAL_GPIO_WritePin(LCD_CTRL_PORT, LCD_RS_PIN, GPIO_PIN_RESET);
HAL_GPIO_WritePin(LCD_CTRL_PORT, LCD_RW_PIN, GPIO_PIN_RESET);
LCD_Write8Bits(cmd >> 8);
LCD_Write8Bits(cmd & 0x0F);
}
void LCD_SendData(uint8_t data) {
HAL_GPIO_WritePin(LCD_CTRL_PORT, LCD_RS_PIN, GPIO_PIN_SET);
HAL_GPIO_WritePin(LCD_CTRL_PORT, LCD_RW_PIN, GPIO_PIN_RESET);
LCD_Write8Bits(data >> 4);
LCD_Write8Bits(data & 0x0F);
}
static void LCD_Enable(void) {
HAL_GPIO_WritePin(LCD_CTRL_PORT, LCD_EN_PIN, GPIO_PIN_RESET);
Delay_us(1);
HAL_GPIO_WritePin(LCD_CTRL_PORT, LCD_EN_PIN, GPIO_PIN_SET);
Delay_us(1);
HAL_GPIO_WritePin(LCD_CTRL_PORT, LCD_EN_PIN, GPIO_PIN_RESET);
Delay_us(100);
}
void LCD_SendString(char *str) {
while (*str) {
LCD_SendData(*str++);
}
}
void LCD_SetCursor(uint8_t row, uint8_t col) {
uint8_t address = (row == 0) ? (0x80 + col) : (0xC0 + col);
LCD_SendCommand(address);
}
void LCD_Clear(void) {
LCD_SendCommand(0x01);
HAL_Delay(2);
}
作者:
Tonghao666
時間:
2025-4-14 15:37
LCD_Init()你這里面初始化函數哪里去了?怎么只有個延時
GPIO也沒有配成輸出模式
還有你的數據發送邏輯,高4位,低四位都沒分清楚啊
估計還有錯,暫且看出這么多
LCD1602指導手冊認真多看兩遍
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1