void LCD_GLASS_Init(void)
{
/*
The LCD is configured as follow:
- clock source = LSE (32.768 KHz)
- Voltage source = Internal
- Prescaler = 2
- Divider = 18 (16 + 2)
- Mode = 1/4 Duty, 1/3 Bias
- LCD frequency = (clock source * Duty) / (Prescaler * Divider)
= 228 Hz ==> Frame frequency = 57 Hz */
CLK_PCKENR2 |= 0x08; // Enable LCD clock
CLK_CRTCR = 0x22; // Set HSI as LCD clock and it is divided by 2
// Initialize the LCD
LCD_FRQ = LCD_Prescaler_64; // Set the prescaler as ClKinput/2
LCD_FRQ |= LCD_Divider_18; // Set the divider as CLKprescaler/18
LCD_CR1 = LCD_Duty_1_4; // Set the duty as 1/4 duty
LCD_CR1 |= LCD_Bias_1_3; // Set the bias as 1/3 bias
LCD_CR2 = LCD_VoltageSource_Internal;// Set Internal voltage source for LCD
// Mask register
LCD_PM0 = 0xFF;
LCD_PM1 = 0x3F;
LCD_PM2 = 0xFF;
LCD_PM3 = 0xFF;
LCD_CR2 |= LCD_Contrast_3V3; // Select the maximum voltage value Vlcd
LCD_CR3 |= LCD_DeadTime_0; // Srt the dead time
LCD_CR2 |= LCD_PulseOnDuration_6; // Set the pulses on duration
LCD_CR3 |= LCD_CR3_LCDEN; // Enable the LCD peripheral
}
|