hxb20122012 发表于 2013-7-24 17:29
在STM8L152R8上有关于LCD控制的介绍!
根据官网上的例子还有网上的一些资料驱动流程都差不多,我也是用库函数来驱动的,不知道是不是硬件有问题,因为屏的引脚比较多,所以走线也相对长了点,最长的大概有个5cm.
程序如下:
(时钟部分初始化)
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
RTC_DeInit();
RTC_WakeUpClockConfig(RTC_WakeUpClock_RTCCLK_Div16);
RTC_SetWakeUpCounter(0x400);
RTC_ITConfig(RTC_IT_WUT, ENABLE);
TimingDelay_Init();
(LCD初始化部分)
LCD_GLASS_Init();
CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE);
CLK_RTCClockConfig(CLK_RTCCLKSource_LSE, CLK_RTCCLKDiv_1);
LCD_Init(LCD_Prescaler_2, LCD_Divider_18, LCD_Duty_1_4,
LCD_Bias_1_3, LCD_VoltageSource_Internal);
//选择seg8-seg15作为LCD段码输入端(stm8l152K6 32pin 无SEG0-SEG7)
//特别注意:STM8L152K6只有4个COM,且固定在PA4\5\6和PD1端口
LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_4, 0xFF);
LCD_PortMaskConfig(LCD_PortMaskRegister_5, 0xFF);
LCD_ContrastConfig(LCD_Contrast_Level_7);
LCD_DeadTimeConfig(LCD_DeadTime_0);
LCD_PulseOnDurationConfig(LCD_PulseOnDuration_1);
LCD_Cmd(ENABLE);
然后就是写数据了
while (1)
{
LCD_WriteRAM(LCD_RAMRegister_0,0xFF);
LCD_WriteRAM(LCD_RAMRegister_1,0xFF);
LCD_WriteRAM(LCD_RAMRegister_2,0xFF);
LCD_WriteRAM(LCD_RAMRegister_3,0xFF);
LCD_WriteRAM(LCD_RAMRegister_4,0xFF);
LCD_WriteRAM(LCD_RAMRegister_5,0xFF);
LCD_WriteRAM(LCD_RAMRegister_6,0xFF);
LCD_WriteRAM(LCD_RAMRegister_7,0xFF);
}
但COM口一直没有波型,搞了几天了,求帮助! |