本帖最后由 568581185 于 2013-1-30 11:59 编辑
5110液晶使用的连接端口是PC0~PC4,之前因为端口复用的问题,郁闷了一下,因为PE口是和陀螺仪、加速度计有连接的,当作输出IO可能会造成端口不能正常地操作。
第一幅图是显示的“STM32F303VCT6
Nokia5110 Test
bbs.21ic.com
ID:568581185”
第二幅图显示的是ST的官方**
第三幅图显示的是21IC电子网的**
以下是图形取模软件设置:必须设置为数据水平、字节垂直。
main.c- /**
- ******************************************************************************
- * @file main.c
- * @author 568581185
- * @version V1.1.0
- * @date 2013-01-28
- * @brief Main program body
- * @pins:
- * Nokia5110:RST=PC0,CE=PC1,DC=PC2,DIN=PC3,CLK=PC4;
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "main.h"
- /* Private variables ---------------------------------------------------------*/
- RCC_ClocksTypeDef RCC_Clocks;
- __IO uint32_t TimingDelay = 0;
- void GPIO_LCD_Init(void)
- {
- /* Configure all the GPIOA in Input Floating mode */
- GPIO_InitTypeDef GPIO_InitStructure;
- RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOC, ENABLE);
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 ;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
- GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
- GPIO_Init(GPIOC, &GPIO_InitStructure);
- }
- /**
- * @brief Main program.
- * @param None
- * @retval None
- */
- int main(void)
- {
-
- SystemInit();
- /* SysTick end of count event each 10ms */
- RCC_GetClocksFreq(&RCC_Clocks);
- SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
-
- GPIO_LCD_Init();
- LCD_Init();
- while (1)
- {
-
- LCD_clear();//必须清除图像数据,以免显示残影的发生
- LCD_write_english_string(0,0,"STM32F303VCT6");
- LCD_write_english_string(0,1,"Nokia5110 Test");
- LCD_write_english_string(0,2,"bbs.21ic.com");
- LCD_write_english_string(0,3,"ID:568581185");
- Delay(1000);//10S
- LCD_draw_bmp_pixel(0,0,gImage_st_**,84 ,48);//显示ST **
- Delay(1000);//10S
- LCD_draw_bmp_pixel(0,0,gImage_21ic,84 ,48);//显示21IC_**
- Delay(1000);//10S
- }
- }
- /**
- * @brief Inserts a delay time.
- * @param nTime: specifies the delay time length, in 10 ms.
- * @retval None
- */
- void Delay(__IO uint32_t nTime)
- {
- TimingDelay = nTime;
- while(TimingDelay != 0);
- }
- /**
- * @brief Decrements the TimingDelay variable.
- * @param None
- * @retval None
- */
- void TimingDelay_Decrement(void)
- {
- if (TimingDelay != 0x00)
- {
- TimingDelay--;
- }
- }
5110液晶相关头文件:
Nokia5110.zip
(5.57 KB, 下载次数: 65)
完整工程文件:
stm32f3_Nokia5110.zip
(2.38 MB, 下载次数: 117)
|