|
時(shí)鐘在外面配置了,在寫(xiě)RAM的時(shí)候?qū)Σ簧咸?hào),看文檔說(shuō)S對(duì)應(yīng)com的SEG,但是無(wú)濟(jì)于事。
- //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
-
- //------打開(kāi)LCD時(shí)鐘------
- CLK->PCKENR2 |= (1<<3);
- // CLK_PCKENR2_PCKEN23=1;//打開(kāi)LCD時(shí)鐘,讀寫(xiě)LCD寄存器用到此時(shí)鐘
- //----設(shè)置LCD預(yù)分頻值----
- LCD_FRQ_PS0=0;// 2^PS[3:0]
- LCD_FRQ_PS1=0;//分頻值為1
- LCD_FRQ_PS2=0;
- LCD_FRQ_PS3=0;
- //----設(shè)置LCD分頻值----
- LCD_FRQ_DIV0=0;//DIV[3:0]+16
- LCD_FRQ_DIV1=0;//分頻值為15+16=31
- LCD_FRQ_DIV2=0;
- LCD_FRQ_DIV3=0;
- //以上分頻值的設(shè)置,最為了得到適合的LCD的刷新頻率,如果增大分頻值,會(huì)導(dǎo)致
- //LCD刷新頻率變低,會(huì)看到LCD顯示出現(xiàn)閃爍
- //比如,我們將PS[3:0]設(shè)置為0011,會(huì)看到液晶閃爍
- //----1/4 duty----
- LCD_CR1_DUTY0=0;//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 */
- //----內(nèi)部電壓源----
- LCD_CR2_VSEL=0;
- //----打開(kāi)引腳的SEG功能----
- //配置正確
- LCD->PM[0]|= 0xfe;//啟用seg0-7
- LCD->PM[1]|= 0x0F;//啟用seg8-10
- //----To set contrast to mean value----
- LCD_CR2_CC0=1;//對(duì)比度
- 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=0;
- LCD_CR2_PON2=0;
- /* 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_CR3_LCDEN=1;
- // LCD->CR4 &=0x00;
- LCD->CR3 |= (0x01<<6);
復(fù)制代碼 |
|