书接上文:
最近在研究用低速、低RAM的单片机来驱动小LCD或TFT彩屏实现动画效果
首先我用一个16MHz晶振的m0内核的8位单片机nRF51822尝试驱动一个1.77寸的4线SPI屏(128X160),
发现,刷一屏大约要0.8s左右的时间,
具体收录在《1、一个简单的nRF51822驱动的天马4线SPI-1.77寸LCD彩屏DEMO》中
觉得,如果用72MHz的STM32也许效果会好很多
于是在stm32上做了个类似的版本,
具体收录在《一个简单的stm32vet6驱动的天马4线SPI-1.77寸LCD彩屏DEMO》中
发现刷一屏0.2s左右,
效果是有的,但是还不能达到支持播放流畅动画的效果!
于是,决定将串行数据改成并行数据传输
本节将带来一个用stm32驱动的2.4寸240X320的8位并口tft屏的刷屏效果
工程结构
main.c
1 /* Includes ------------------------------------------------------------------*/ 2 #include "stm32f10x.h" 3 #include "LCD2.h" 4 5 6 void RCC_Configuration(void); 7 /**************************************************************************** 8 * 名 称:int main(void) 9 * 功 能:主函数 10 * 入口参数:无 11 * 出口参数:无 12 * 说 明: 13 * 调用方法:无 14 ****************************************************************************/ 15 int main(void) 16 { 17 RCC_Configuration(); //系统时钟配置 18 LCD2_GPIO_Init(); 19 LCD2_Init(); 20 while (1) 21 { 22 Show_RGB(0,240,0,320,0xff0f); 23 DELAY_MS(1000); 24 Show_RGB(0,240,0,320,0x00fe); 25 DELAY_MS(1000); 26 } 27 } 28 29 /**************************************************************************** 30 * 名 称:void RCC_Configuration(void) 31 * 功 能:系统时钟配置为72MHZ 32 * 入口参数:无 33 * 出口参数:无 34 * 说 明: 35 * 调用方法:无 36 ****************************************************************************/ 37 void RCC_Configuration(void) 38 { 39 SystemInit(); 40 }
LCD2.c
1 #include "LCD2.h" 2 3 4 5 void LCD2_GPIO_Init() 6 { 7 GPIO_InitTypeDef GPIO_InitStructure; 8 9 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); 10 11 12 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9; 13 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 14 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //口线翻转速度为50MHz 15 GPIO_Init(GPIOB, &GPIO_InitStructure); 16 17 //8位数据输出 18 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; 19 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 20 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //口线翻转速度为50MHz 21 GPIO_Init(GPIOD, &GPIO_InitStructure); 22 } 23