void LCD_Config(void)
{
//SEG GPIO Init
GPIO_Init(GPIOE, GPIO_Pin_0|GPIO_Pin_1,GPIO_Mode_Out_PP_Low_Fast);//SEG1,2
GPIO_Init(GPIOE, GPIO_Pin_2|GPIO_Pin_3,GPIO_Mode_Out_PP_Low_Fast);//SEG3,4
GPIO_Init(GPIOE, GPIO_Pin_4|GPIO_Pin_5,GPIO_Mode_Out_PP_Low_Fast);//SEG5,6
GPIO_Init(GPIOD, GPIO_Pin_0|GPIO_Pin_2,GPIO_Mode_Out_PP_Low_Fast);//SEG7,8
GPIO_Init(GPIOD, GPIO_Pin_3,GPIO_Mode_Out_PP_Low_Fast);//SEG9
GPIO_Init(GPIOB, GPIO_Pin_0|GPIO_Pin_1,GPIO_Mode_Out_PP_Low_Fast);//SEG10,11
//COM GPIO Init
GPIO_Init(GPIOF, GPIO_Pin_4|GPIO_Pin_5,GPIO_Mode_Out_PP_Low_Fast);//COM4,5
GPIO_Init(GPIOF, GPIO_Pin_6|GPIO_Pin_7,GPIO_Mode_Out_PP_Low_Fast);//COM6,7
//------打开LCD时钟------
CLK->PCKENR2 |= (1<<3);
//----设置LCD预分频值----
LCD_FRQ_PS0=0;// 2^PS[3:0]
LCD_FRQ_PS1=0;//分频值为0
LCD_FRQ_PS2=0;
LCD_FRQ_PS3=0;
//----设置LCD分频值----
LCD_FRQ_DIV0=0;//DIV[3:0]+16
LCD_FRQ_DIV1=0;//分频值为16
LCD_FRQ_DIV2=0;
LCD_FRQ_DIV3=0;
//----1/4 duty----
LCD_CR1_DUTY0=1;//1/4 duty
LCD_CR1_DUTY1=1;
/* Duty ratio selection
00: Static duty
01: 1/2 duty
10: 1/3 duty
11: 1/4 duty */
//----1/3 bias----
LCD_CR1_B2=0;//1/3 bias
/* 0: 1/3 bias
1: 1/2 bias */
//----内部电压源----
LCD_CR2_VSEL=0;
//----打开引脚的SEG功能----
LCD->PM[0]|= 0xFE;//启用seg0-7
LCD->PM[1]|= 0x0F;//启用seg8-10
//----To set contrast to mean value----
LCD_CR2_CC0=1;//对比度
LCD_CR2_CC1=1;
LCD_CR2_CC2=1;
/* 000: VLCD0 2.6V
001: VLCD1 2.7V
010: VLCD2 2.8V
011: VLCD3 2.9V
100: VLCD4 3.0V
101: VLCD5 3.1V
110: VLCD6 3.2V
111: VLCD7 */
//----Dead time 0----
LCD_CR3_DEAD0=0;//no dead time
LCD_CR3_DEAD1=0;
LCD_CR3_DEAD2=0;
//----LCD_PulseOnDuration_1----
LCD_CR2_PON0=1;
LCD_CR2_PON1=1;
LCD_CR2_PON2=1;
/* 000: 0 CLKps pulses
001: 1 CLKps pulses
010: 2 CLKps pulses
011: 3 CLKps pulses
100: 4 CLKps pulses
101: 5 CLKps pulses
110: 6 CLKps pulses
111: 7 CLKps pulses */
//----Enable LCD peripheral----
// LCD->CR4 |=0x04;
LCD->CR3 |= (0x01<<6);
}
//带初始化
void test_LCD(void)
{
LCD_Config();
unsigned char i=0;
uint8_t volatile *LCDRAMAddr = &(LCD->RAM[8]);
//
// while(i<14)
// {
// LCD->RAM[i++] = 0x02;
// }
LCD->RAM[8] = 0x02;
while(1)
{
}
} 会显示三个点,很奇怪。
附上我的图
|