上电要上几次才正常显示一次。不知道啥原因。
VLCD接VDDA。
void main(void)
{
Init_CLK(); //Init. Clock
Init_GPIO(); //Init. GPIO
LCD_Init(); //Init. LCD Drive
;
;
}
void LCD_Init(void)
{
/*
The LCD is configured as follow:
- clock source = HSI (16MHz) / 16 = 1MHz (RTCCLK = 16MHz / 16 = 1MHz), fIN = RTCCLK/2 = 500kHz
- Voltage source = Internal
- Prescaler = 5
- Divider = 26 (16 + 10)
- Mode = 1/8 Duty, 1/4 Bias
- LCD frequency = (clock source) / (Prescaler * Divider)
= (500k) /(2^5 * 26) = 600.96 Hz ==> Frame frequency = 600.96 Hz * duty = 600.96 * 1/8 Hz = 75.12 Hz
*/
/* Enable LCD clock */
// CLK_PeripheralClockConfig(CLK_Peripheral_LCD, ENABLE);
// CLK_RTCClockConfig(CLK_RTCCLKSource_HSI, CLK_RTCCLKDiv_16); //RTCCLK = 16MHz /16 = 1MHz
/* Initialize the LCD */
LCD_Init(LCD_Prescaler_32, LCD_Divider_26, LCD_Duty_1_8,
LCD_Bias_1_4, LCD_VoltageSource_Internal); //1/8 Duty, 1/4 Bias, Internal VLCD
/* Mask register*/
LCD_PortMaskConfig(LCD_PortMaskRegister_0, 0xFF); //SEG0 ~ SEG7
LCD_PortMaskConfig(LCD_PortMaskRegister_1, 0x0F); //SEG8 ~ SEG11, Unused pins as general purpose I/Os
LCD_PortMaskConfig(LCD_PortMaskRegister_2, 0x00); //Unused pins as general purpose I/Os
LCD_PortMaskConfig(LCD_PortMaskRegister_3, 0x00); //Unused pins as general purpose I/Os
LCD_ContrastConfig(LCD_Contrast_3V3);
// LCD_DeadTimeConfig(LCD_DeadTime_0);
LCD_DeadTimeConfig(LCD_DeadTime_1);
LCD_PulseOnDurationConfig(LCD_PulseOnDuration_7);
LCD_HighDriveCmd(ENABLE);
LCD_Cmd(ENABLE); /*!< Enable LCD peripheral */ //LCD Controller enable
} |