STM32F4 LTDC学习
很久没有写东西了,也很久没看文档了吼吼,觉得有点无聊,找来F4看看,主要看F429。督促自己多看多记录。
首先配置同步时序先看参考手册
下面看一个实际例子,一块439的开发板
设置:
LTDC_InitStruct.LTDC_HorizontalSync = ;
/* */
LTDC_InitStruct.LTDC_VerticalSync = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedHBP = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedVBP = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedActiveW = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedActiveH = ;
/* */
LTDC_InitStruct.LTDC_TotalWidth = ;
/* */
LTDC_InitStruct.LTDC_TotalHeigh = ; LTDC_Init(<DC_InitStruct);
配置时序
注意每个参数定义,之前是累加
看下完整的初始化代码
void LCD_Init(void)
{
LTDC_InitTypeDef LTDC_InitStruct;
LTDC_Layer_InitTypeDef LTDC_Layer_InitStruct;
LTDC_Layer_TypeDef LTDC_Layerx; /* IO¿Ú³õʼ»¯ */
LCD_GPIOInit(); LCD_DisplayOff();
/* ʹÄÜLCDʱÖÓ */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_LTDC, ENABLE);
/* ʹÄÜDMAʧ×Ù*/
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2D, ENABLE); /* ˮƽͬ²½ÐźÅ---µÍµçƽÓÐЧ */
LTDC_InitStruct.LTDC_HSPolarity = LTDC_HSPolarity_AL;
/* ´¹Ö±Í¬²½ÐźÅ---µÍµçƽÓÐЧ */
LTDC_InitStruct.LTDC_VSPolarity = LTDC_VSPolarity_AL;
/* Êý¾ÝʹÄÜÐźÅ---µÍµçƽÓÐЧ */
LTDC_InitStruct.LTDC_DEPolarity = LTDC_DEPolarity_AL;
/* ÏñËØÊ±ÖÓÅäÖÃ--- */
LTDC_InitStruct.LTDC_PCPolarity = LTDC_DEPolarity_AL;
/* LCD±³¹âÉèÖà */
LTDC_InitStruct.LTDC_BackgroundRedValue = ;
LTDC_InitStruct.LTDC_BackgroundGreenValue = ;
LTDC_InitStruct.LTDC_BackgroundBlueValue = ;
/*
****************************************************************************
*PLLSAI_VCO = HSE*PLLSAI_N / PLL_M = 8 * 192 / 8 = 192MHz
*PLLLCDCLK = PLLSAI_VCO / PLLSAI_R = 192 / 3 = 64 Mhz
*LTDC clock frequency = PLLLCDCLK / RCC_PLLSAIDivR = 64 / 8 = 8 Mhz
****************************************************************************
*/
RCC_PLLSAIConfig(, , );
RCC_LTDCCLKDivConfig(RCC_PLLSAIDivR_Div4);
/* ʹÄÜPLLSAIʱÖÓ */
RCC_PLLSAICmd(ENABLE);
/* µÈ´ýPLLSAIʱÖÓ */
while(RCC_GetFlagStatus(RCC_FLAG_PLLSAIRDY) == RESET){}
/* */
LTDC_InitStruct.LTDC_HorizontalSync = ;
/* */
LTDC_InitStruct.LTDC_VerticalSync = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedHBP = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedVBP = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedActiveW = ;
/* */
LTDC_InitStruct.LTDC_AccumulatedActiveH = ;
/* */
LTDC_InitStruct.LTDC_TotalWidth = ;
/* */
LTDC_InitStruct.LTDC_TotalHeigh = ; LTDC_Init(<DC_InitStruct); LTDC_Layer_InitStruct.LTDC_HorizontalStart = ;
LTDC_Layer_InitStruct.LTDC_HorizontalStop = ( + - );
LTDC_Layer_InitStruct.LTDC_VarticalStart = ;
LTDC_Layer_InitStruct.LTDC_VerticalStop = ( + - ); /* Pixel Format configuration*/
LTDC_Layer_InitStruct.LTDC_PixelFormat = LTDC_Pixelformat_RGB565;
/* Alpha constant (255 totally opaque) */
LTDC_Layer_InitStruct.LTDC_ConstantAlpha = ;
/* Default Color configuration (configure A,R,G,B component values) */
LTDC_Layer_InitStruct.LTDC_DefaultColorBlue = ;
LTDC_Layer_InitStruct.LTDC_DefaultColorGreen = ;
LTDC_Layer_InitStruct.LTDC_DefaultColorRed = ;
LTDC_Layer_InitStruct.LTDC_DefaultColorAlpha = ;
/* Configure blending factors */
LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_CA;
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_CA;
/* the length of one line of pixels in bytes + 3 then :
Line Lenth = Active high width x number of bytes per pixel + 3
Active high width = LCD_PIXEL_WIDTH
number of bytes per pixel = 2 (pixel_format : RGB565)
*/
LTDC_Layer_InitStruct.LTDC_CFBLineLength = (( * ) + );
/* the pitch is the increment from the start of one line of pixels to the
start of the next line in bytes, then :
Pitch = Active high width x number of bytes per pixel
*/
LTDC_Layer_InitStruct.LTDC_CFBPitch = ( * );
/* configure the number of lines */
LTDC_Layer_InitStruct.LTDC_CFBLineNumber = ; /* Input Address configuration */
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER; LTDC_LayerInit(LTDC_Layer1, <DC_Layer_InitStruct); /* Configure Layer2 */
LTDC_Layer_InitStruct.LTDC_CFBStartAdress = LCD_FRAME_BUFFER + BUFFER_OFFSET;
LTDC_Layer_InitStruct.LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;
LTDC_Layer_InitStruct.LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
LTDC_LayerInit(LTDC_Layer2, <DC_Layer_InitStruct); LTDC_ReloadConfig(LTDC_IMReload); /* Enable foreground & background Layers */
LTDC_LayerCmd(LTDC_Layer1, ENABLE);
// LTDC_LayerCmd(LTDC_Layer2, ENABLE);
LTDC_ReloadConfig(LTDC_IMReload); LCD_DisplayOn();
}
LCD_Init
LTDC_DefaultColorBlue就是背景色
每个Layer支持窗口(Window)操作,所谓Window,就是指该层的图像只有在Window区域内有效,而Window区域外则用该层的DefaultColor填充。如下图:
填色直接写内存
int main (void)
{
uint32_t i, j;
uint16_t *addr = (uint16_t *)LCD_FRAME_BUFFER; SDRAM_Init();
LCD_Init();
j = ;
while () { for (i = ; i < 0x2000000;i++);
for (i = ; i < * ; i++)
{
addr[i] = << j;
}
j++;
if (j > )j = ;
}
}
LCD display RGB
STM32F4 LTDC学习的更多相关文章
- STM32F4 LTDC
首先配置同步时序先看参考手册 下面看一个实际例子,一块439的开发板 设置: 配置时序 LTDC_InitStruct.LTDC_HorizontalSync = ; /* */ LTDC_InitS ...
- STM32F4编程手册学习2_内存模型
STM32F4编程手册学习2_内存模型 1. 内存映射 MCU将资源映射到一段固定的4GB可寻址内存上,如下图所示. 内存映射将内存分为几块区域,每一块区域都有一个定义的内存类型,一些区域还有一些附加 ...
- STM32F4 编程手册学习1_编程模型
STM32F4 programming manual_1 1. 处理器模式与特权等级 处理器模式分为以下两种: 线程模式: 用来执行应用软件: 处理器从reset出来时,进入线程模式: CONTROL ...
- STM32F4时钟配置分析
//学习STM32F4的过程中关于时钟上面讲的比较好 特地转发与大家分享 STM32F4时钟设置分析 原文博客链接:http://blog.csdn.net/jdh99,作者:jdh,转载请注明. 环 ...
- STM32学习笔记(二)——串口控制LED
开发板芯片:STM32F407ZGT6 PA9-USART1_TX,PA10-USART1_RX; PF9-LED0,PF10-LED1; 一.串口1配置过程(不使用串口中断): 1.使能时钟,包括G ...
- STM32学习笔记(三)——外部中断的使用
开发板芯片:STM32F407ZGT6 硬件连接:PE3-KEY1 一.STM32F4的中断介绍 STM32F4的每个IO都可以作为外部中断输入,很强大的功能吧!以前学习的51只有两个外部中断. ST ...
- STM32学习笔记(四)——串口控制LED(中断方式)
目录: 一.时钟使能,包括GPIO的时钟和串口的时钟使能 二.设置引脚复用映射 三.GPIO的初始化配置,注意要设置为复用模式 四.串口参数初始化配置 五.中断分组和中断优先级配置 六.设置串口中断类 ...
- STM32学习笔记:【001】常见数据查阅
了方便开发学习,现整理在学习过程中经常查阅的资料 (注意,以下资料都可以在ST给出官方手册中查到) 本人所持型号:STM32F429ZI-DISCOVERY, 芯片内核 :Cortex - ...
- STM32学习笔记:【001】时钟树与RCC
导言 如果学过单片机的同学应该不会陌生,学习51单片机时最经常听到的就是“最小系统”. 最小系统里面少不了晶振,否则单片机无法工作. 单片机需要晶振(时钟源)来工作,那么对于STM32芯片同样如此. ...
随机推荐
- hdu 2167 状态压缩
/*与1565的解法差不多*/ #include<stdio.h> #include<string.h> int map[16][16]; int dp[2][1<< ...
- MySQL介绍及安装&MySQL软件基本管理
mysql介绍 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB 公司开发,目前属于 Oracle 旗下公司.MySQL 最流行的关系型数据库管理系统,在 WEB 应用方面MySQL是最好 ...
- python学习之 - re模块
re模块功能:实现字符串匹配. 元字符 描述\ 将下一个字符标记符.或一个向后引用.或一个八进制转义符.例如,“\\n”匹配\n.“\n”匹配换行符.序列“\\”匹配“\”而“\(”则匹配“(”.即相 ...
- Baby Step Giant Step model
******************************************** */ #include <stdio.h> #include <string.h> # ...
- 【python】SHA1 算法
http://blog.163.com/sh_wenfen/blog/static/99708242007231103936938/
- [转]thrift系列 - 快速入门
原文: http://blog.csdn.net/hrn1216/article/details/51274934 thrift 介绍,入门例子. thrift 是一个RPC框架,实现跨语言 ---- ...
- Word 2013安裝字典
不必從內建的字典中開始,Word 2013 可將您連結到 Office 市集,方便您挑選免費的字典,或從包括多語字典的字典集合中購買. 若要選擇並安裝您想要的字典,請以滑鼠右鍵按一下任何單字,並按一下 ...
- uva 10069 Distinct Subsequences 【dp+大数】
题目:uva 10069 Distinct Subsequences 题意:给出一个子串 x 和母串 s .求子串在母串中的不同序列的个数? 分析:定义dp[i][j]:x 的前 i 个字母在 s 的 ...
- webservice0基础
在学习webservice的时候,常常将ns和url花了好久时间才理解过来,这里备份下. 首先定义接口: @WebService public interface IService { @WebRes ...
- Redis 命令行 常用总结
http://www.redis.cn/commands.html# 1 Keys * 列出所有的keys redis > keys * ) "s:0" ) "o: ...