最近在做一个基于stm8l152r8t6的段式LCD液晶显示屏的驱动程序,从网上找了一些资料,然后用官方的库函数写了一下驱动程序,但是不知道为什么LCD就是点不亮,已经调试了两三天了,请哪位大神帮忙给我看看到底是什么地方出现了问题?下边是我写的程序源代码。
/* MAIN.C file
*
* Copyright (c) 2002-2005 STMicroelectronics
*/
#include "lcd.h"
#include "gpio.h"
const uint8_t CapLetterMap[10]=
{
/* 0 1 2 3 4 5 6 7 8 9*/
0xFC, 0x60, 0xDA, 0xF2, 0x66, 0xB6, 0xBE, 0xE0, 0xFE, 0xF6
};
KEY_Init(void)
{
GPIO_DeInit(GPIOG);
GPIO_Init(GPIOG, GPIO_Pin_0, GPIO_Mode_In_FL_No_IT); //PG0 浮空输入无中断
GPIO_Init(GPIOG, GPIO_Pin_1, GPIO_Mode_In_FL_No_IT); //PG1 浮空输入无中断
GPIO_Init(GPIOG, GPIO_Pin_2, GPIO_Mode_In_FL_No_IT);
GPIO_Init(GPIOG, GPIO_Pin_3, GPIO_Mode_In_FL_No_IT);
}
int main(void)
{
//按键初始化
KEY_Init();
/*LCD 时钟使能*/
CLK_SYSCLKSourceConfig(CLK_SYSCLKSource_HSI); //选择HSI为系统时钟 16Mhz
CLK_RTCClockConfig(CLK_RTCCLKSource_HSI, CLK_RTCCLKDiv_64); //16Mhz/64= 250Khz
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE);
CLK_HSICmd(ENABLE); //使能HSI时钟
/* Initialize the LCD */
LCD_Init(LCD_Prescaler_2, LCD_Divider_18, LCD_Duty_1_4,
LCD_Bias_1_3, LCD_VoltageSource_Internal);
/*LCD初始化及配置使能*/
LCD_DeInit();
//FCK=125000/2^5*16=128000/512=244 Frame=244/4=61HZ
//LCD_Init(LCD_Prescaler_32, LCD_Divider_16, LCD_Duty_1_4, LCD_Bias_1_3, LCD_VoltageSource_Internal);
/*seg 0 1 2 3 4 5 6 7 */
LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xFE);
/*seg 8 9 10 11 12 13 14 15*/
LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0xFE);
/*seg 16 17 18 19 20 21 22 23*/
LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0xFE);
/*seg 24*/
LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0x01);
LCD_ContrastConfig(LCD_Contrast_3V0); //LCD屏幕对比度
LCD_DeadTimeConfig(LCD_DeadTime_0); //LCD液晶的死区时间
LCD_PulseOnDurationConfig(LCD_PulseOnDuration_7); //脉冲持续时间
LCD_BlinkConfig(LCD_BlinkMode_SEG0_AllCOM, LCD_BlinkFrequency_Div1024);
LCD_PageSelect(LCD_PageSelection_SecondPage); //页选择 COM1 COM2 COM3 COM4
LCD_Cmd(ENABLE);
while(1)
{
LCD_WriteRAM(LCD_RAMRegister_10, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_9, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_8, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_7, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_6, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_5, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_4, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_3, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_2, 0xFF);
LCD_WriteRAM(LCD_RAMRegister_1, 0xFF);
}
return 0;
} |
|