金牌会员
- 积分
- 1027
- 金钱
- 1027
- 注册时间
- 2021-2-4
- 在线时间
- 146 小时
|
1金钱
如题: 初始化完后显示的是两行黑格VO通过1K电阻接到GND
供电是5V 信号是3.3V 用的STM32F103C8
代码如下(工程在附件里):
void BSP_LCD_Init(void)
{
BSP_LCD1602_0.LCD_DB0_Pinx = LCD_DB0_Pin;
BSP_LCD1602_0.LCD_DB0_Portx = LCD_DB0_GPIO_Port;
BSP_LCD1602_0.LCD_DB1_Pinx = LCD_DB1_Pin;
BSP_LCD1602_0.LCD_DB1_Portx = LCD_DB1_GPIO_Port;
BSP_LCD1602_0.LCD_DB2_Pinx = LCD_DB2_Pin;
BSP_LCD1602_0.LCD_DB2_Portx = LCD_DB2_GPIO_Port;
BSP_LCD1602_0.LCD_DB3_Pinx = LCD_DB3_Pin;
BSP_LCD1602_0.LCD_DB3_Portx = LCD_DB3_GPIO_Port;
BSP_LCD1602_0.LCD_DB4_Pinx = LCD_DB4_Pin;
BSP_LCD1602_0.LCD_DB4_Portx = LCD_DB4_GPIO_Port;
BSP_LCD1602_0.LCD_DB5_Pinx = LCD_DB5_Pin;
BSP_LCD1602_0.LCD_DB5_Portx = LCD_DB5_GPIO_Port;
BSP_LCD1602_0.LCD_DB6_Pinx = LCD_DB6_Pin;
BSP_LCD1602_0.LCD_DB6_Portx = LCD_DB6_GPIO_Port;
BSP_LCD1602_0.LCD_DB7_Pinx = LCD_DB7_Pin;
BSP_LCD1602_0.LCD_DB7_Portx = LCD_DB7_GPIO_Port;
BSP_LCD1602_0.LCD_RS_Pinx = LCD_RS_Pin;
BSP_LCD1602_0.LCD_RS_Portx = LCD_RS_GPIO_Port;
BSP_LCD1602_0.LCD_RW_Pinx = LCD_RW_Pin;
BSP_LCD1602_0.LCD_RW_Portx = LCD_RW_GPIO_Port;
BSP_LCD1602_0.LCD_EN_Pinx = LCD_EN_Pin;
BSP_LCD1602_0.LCD_EN_Portx = LCD_EN_GPIO_Port;
for (uint8_t i = 0; i < LCD_SUM; i++)
{
LCD_Array[i].CMD = 0;
LCD_Array[i].Data = 0;
LCD_Array[i].Flag_Enable = 0;
}
HAL_Delay(15);
BSP_LCD_Write_CMD(&BSP_LCD1602_0, 0x38);
HAL_Delay(5);
BSP_LCD_Write_CMD(&BSP_LCD1602_0, 0x0c);
HAL_Delay(5);
BSP_LCD_Write_CMD(&BSP_LCD1602_0, 0x06);
HAL_Delay(5);
BSP_LCD_Write_CMD(&BSP_LCD1602_0, 0x01);
HAL_Delay(5);
// BSP_LCD_Write_CMD(&BSP_LCD1602_0, 0x38);
}
void BSP_LCD_Write_CMD(LCD_Conf *LCD_Struct, uint8_t CMD)
{
LCD_RS_PIN(GPIO_PIN_RESET);
LCD_RW_PIN(GPIO_PIN_RESET);
LCD_EN_PIN(GPIO_PIN_RESET);
LCD_DATA_PIN = CMD;
HAL_Delay(2);
LCD_EN_PIN(GPIO_PIN_SET);
HAL_Delay(2);
LCD_EN_PIN(GPIO_PIN_RESET);
}
void BSP_LCD_Write_Data(LCD_Conf *LCD_Struct, uint8_t Data)
{
LCD_RS_PIN(GPIO_PIN_SET);
LCD_RW_PIN(GPIO_PIN_RESET);
LCD_EN_PIN(GPIO_PIN_RESET);
LCD_DATA_PIN = Data;
HAL_Delay(2);
LCD_EN_PIN(GPIO_PIN_SET);
HAL_Delay(2);
LCD_EN_PIN(GPIO_PIN_RESET);
}
|
|