贴上LCD屏幕资料、真值表及驱动程序,但无法做到像数码管一样,每个位都可以单独显示对应段码,比如我要显示千分位的驱动如下:
https://bbs.21ic.com/forum.php?mod=attachment&aid=MTUxOTU4MnwwODM2Yjg3ZWEzMzc3YjM0OWVhYmQ3NDJiMDU0YjFhNHwxNzMyMjc2MDkz&request=yes&_f=.pngattach://1519580.png
STM8L的LCD驱动初始化正常,可以显示字段,但无法按要求显示0-9字符;
void LCD_Config(void)
{
/* Enable RTC CLK */
CLK_PeripheralClockConfig(CLK_Peripheral_RTC, ENABLE);
/* Enable RTC CLK */
CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE);
/* Choice CLK Source, HSI_Freq = 16M, RTC_Freq = 500Khz*/
CLK_RTCClockConfig(CLK_RTCCLKSource_HSI,CLK_RTCCLKDiv_32);
/* Frequence = 500K/(32+16) Frame_Freq = Frequence/Duty = 60Hz */
LCD_Init(LCD_Prescaler_32, LCD_Divider_16, LCD_Duty_1_8,
LCD_Bias_1_3, LCD_VoltageSource_External); //采用外部电源-欧阳;
/* Enable PM */
LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xFF); //PM0=1111 1111 也就是开通SEG0-SEG7
LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0x01); //PM1= 0000 0001 也就是开通SEG8
// LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0x00);
// LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0x00);
// LCD_PortMaskConfig(LCD_PortMaskRegister_4, 0x00);
// LCD_PortMaskConfig(LCD_PortMaskRegister_5, 0x00);
/* LCD_Contrast_Level_7: Medium Density / High Density Maximum Voltage = 3.30V / 3.51V */
LCD_ContrastConfig(LCD_Contrast_3V0); //亮度高,通过实践调节亮度;在stm8l15x_lcd.h中;
/* No dead time */
LCD_DeadTimeConfig(LCD_DeadTime_0);
/* LCD_PulseOnDuration_7: Pulse ON duration = 7/CLKprescaler */
LCD_PulseOnDurationConfig(LCD_PulseOnDuration_7);
LCD_Cmd(ENABLE);
}
比如驱动程序对应
//0-9;如1:A B C D E F G H Dp;0110 0000 = 0X60;
// 0 1 2 3 4 5 6 7 8 9
const unsigned int LCD_MODEL[10] = {0xFC,0X60,0XDA,0XF2,0X66,0XB6,0XB3,0XE0,0XFE,0XF6};
void dis(u16 dis_num) //0-9999
{
u8 num;
num=(u8)(dis_num/1000%10);// 4 显示最高千分位;
//清除A段;COM1
LCD->RAM[LCD_RAMRegister_1]&=(~0x01);
LCD->RAM[LCD_RAMRegister_1] |=((LCD_MODEL[num]>>7 )&(0x01)); //4A 在【7】,RAM在0位;右移动7bit 7-0
LCD->RAM[LCD_RAMRegister_0]&=(~0x80);
LCD->RAM[LCD_RAMRegister_0] |=((LCD_MODEL[num]<<1 )&(0x80)); //4B =COM1 6-7
LCD->RAM[LCD_RAMRegister_7]&=(~0x80);
LCD->RAM[LCD_RAMRegister_7] |=((LCD_MODEL[num] <<2 )&(0x80)); //4C =COM3 5-7
LCD->RAM[LCD_RAMRegister_11]&=(~0x10);
LCD->RAM[LCD_RAMRegister_11] |=((LCD_MODEL[num] )&(0x10)); //4D =COM4 4-4
LCD->RAM[LCD_RAMRegister_8]&=(~0x01);
LCD->RAM[LCD_RAMRegister_8] |=((LCD_MODEL[num] >>3 )&(0x01)); //4E =COM3 3-0
LCD->RAM[LCD_RAMRegister_4]&=(~0x10);
LCD->RAM[LCD_RAMRegister_4] |=((LCD_MODEL[num]<<2 )&(0x10)); //4F =COM2 2-4
LCD->RAM[LCD_RAMRegister_4]&=(~0x08);
LCD->RAM[LCD_RAMRegister_4] |=((LCD_MODEL[num]<<2 )&(0x08)); //4G =COM2 1-3
LCD->RAM[LCD_RAMRegister_11]&=(~0x08);
LCD->RAM[LCD_RAMRegister_11] |=((LCD_MODEL[num]<<3)&(0x08)); //4H P4 =COM4 0-3
}
在main函数中对LCD初始化之后,调用dis(2345);显示出来的千分位结果是8.,一直无法解决,有能力解决者联系我,谢谢!
|