【瑞萨RA8D1开发板,基于M85内核的图形MCU测评】+测试RGB屏幕
<div class='showpostmsg'><p>底板绘制好了,然后我们可以开始测试我们的接口了,先测试下我们的50P的RGB接口。</p><p > </p>
<p >看下我们的接口我们默认的TCON是随便接的。然后我们现在只能是RGB666模式,有低位两个接地了。</p>
<p > </p>
<p >看手册,我们是RGB666的大端接法,程序中不要错了。我们看下框架吧,我对RGB的驱动还是比较陌生的。</p>
<p > </p>
<p >我理解Graphics 1和Graphics 2,两个是负责图像数据处理的,两个数据应该可以叠加显示,但目前我看都是用一个,只需要往Graphics 的data buffer里面填充数据,然后他就能刷新到我们屏幕上。</p>
<p > </p>
<p >接下来就是进入e2 studio里面创建工程,实际我感觉用会e2 studio要方便很多。配置工程要用到的管脚。</p>
<p > </p>
<p >配置有一个方便的功能,可以选择AB,这样下面的管脚选错就会报出来,我们用到的都是LCD_B的管脚,在管脚说明上也是有的。</p>
<p > </p>
<p >然后配置下外部的SDRAM,不使用外部的SDRAM主要应该是怕缓存不够。</p>
<p > </p>
<p >输入这里选择RGB565或者RGB888这种只是输入图像的数据,这里就决定了我们的图像到时候怎么拼接,送到我们的Graphics 的data buffer中。宽高和我们显示屏一致。</p>
<p > </p>
<p >输出这里我们要配置我们屏幕的时序,然后什么样类型数据,是RGB格式还是BGR,因为存在这种比较方便我们布线,还有大小端。我们自然要配置大端RGB格式。</p>
<p > </p>
<p >之后就是程序了,这里我用了下RA8D1的官方例程,每次实际就是用指针对里面数据进行更新。加人我们用的SDRAM驱动。同时控制背光脚,我们先不配置为PWM方式,我们改成直接IO输出方便测试。</p>
<p > </p>
<p >直接上电就为高,方便测试。</p>
<p > </p>
<p >接上屏幕可以直接看到显示,通过仿真我们也是可以看到图像数据的,主要就是那个buff。</p>
<p > </p>
<p > </p>
<p >仿真也是可以看到里面的数据。</p>
<p >主要代码:</p>
<pre>
<code>#include "hal_data.h"
#include "glcdc_ep.h"
#include "board_sdram.h"
FSP_CPP_HEADER
void R_BSP_WarmStart(bsp_warm_start_event_t event);
FSP_CPP_FOOTER
/* Variables to store resolution information */
uint16_t g_hz_size, g_vr_size;
/* Variables used for buffer usage */
uint32_t g_buffer_size;
uint8_t * g_p_single_buffer, * g_p_double_buffer;
#define RESET_VALUE (0x00)
static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color);
static void color_band_display(void);
/*******************************************************************************************************************//**
* main() is generated by the RA Configuration editor and is used to generate threads if an RTOS is used.This function
* is called by main() when no RTOS is used.
**********************************************************************************************************************/
void hal_entry(void)
{
fsp_err_t err = FSP_SUCCESS;
/* TODO: add your own code here */
#if BSP_TZ_SECURE_BUILD
/* Enter non-secure code */
R_BSP_NonSecureEnter();
#endif
bsp_sdram_init();
/* Get LCDC configuration */
g_hz_size = (g_display_cfg.input.hsize);
g_vr_size = (g_display_cfg.input.vsize);
/* Initialize buffer pointers */
g_buffer_size = (uint32_t) (g_hz_size * g_vr_size * BYTES_PER_PIXEL);
g_p_single_buffer = (uint8_t *) g_display_cfg.input.p_base;
/* Double buffer for drawing color bands with good quality */
g_p_double_buffer = g_p_single_buffer + g_buffer_size;
/* Initialize GLCDC driver */
err = R_GLCDC_Open(&g_display_ctrl, &g_display_cfg);
/* Initialize GLCDC driver */
err = R_GLCDC_Open(&g_display_ctrl, &g_display_cfg);
/* Handle error */
// if(FSP_SUCCESS != err)
// {
// /* GLCDC initialization failed*/
// APP_ERR_PRINT("\r\n ** GLCDC driver initialization FAILED ** \r\n");
// APP_ERR_TRAP(err);
// }
/* Start GLCDC display output */
err = R_GLCDC_Start(&g_display_ctrl);
/* Handle error */
// if(FSP_SUCCESS != err)
// {
// /* GLCDC initialization failed*/
// APP_ERR_PRINT("\r\n ** GLCDC driver start FAILED ** \r\n");
// APP_ERR_TRAP(err);
// }
/* Clear LCD screen using appropriate co-ordinates */
screen_display((uint16_t)X1_CO_ORDINATE, (uint16_t)Y1_CO_ORDINATE, g_hz_size, g_vr_size, BLACK);
/* Display color bands on LCD screen */
color_band_display();
}
/*******************************************************************************************************************//**
* This function is called at various points during the startup process.This implementation uses the event that is
* called right before main() to set up the pins.
*
* @paramevent Where at in the start up process the code is currently at
**********************************************************************************************************************/
void R_BSP_WarmStart(bsp_warm_start_event_t event)
{
if (BSP_WARM_START_RESET == event)
{
#if BSP_FEATURE_FLASH_LP_VERSION != 0
/* Enable reading from data flash. */
R_FACI_LP->DFLCTL = 1U;
/* Would normally have to wait tDSTOP(6us) for data flash recovery. Placing the enable here, before clock and
* C runtime initialization, should negate the need for a delay since the initialization will typically take more than 6us. */
#endif
}
if (BSP_WARM_START_POST_C == event)
{
/* C runtime environment and system clocks are setup. */
/* Configure pins. */
R_IOPORT_Open (&IOPORT_CFG_CTRL, &IOPORT_CFG_NAME);
#if BSP_CFG_SDRAM_ENABLED
/* Setup SDRAM and initialize it. Must configure pins first. */
R_BSP_SdramInit(true);
#endif
}
}
static void screen_display(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint32_t color)
{
/*Declare local variables */
uint16_t start_x, start_y, display_length, display_height;
uint32_t start_addr;
/* Assign co-ordinate values and calculate start address */
start_x = x1;
start_y = y1;
start_addr = (uint32_t)((start_x * BYTES_PER_PIXEL) + (start_y * g_hz_size* BYTES_PER_PIXEL));
/* Calculate display box length and height */
display_length = (uint16_t)((x2 - x1) * BYTES_PER_PIXEL);
display_height = (y2 - y1);
/* Display required color band */
for(uint16_t ver_value = Y1_CO_ORDINATE; ver_value < (display_height - INC_DEC_VALUE); ver_value++)
{
for(uint32_t hor_value = start_addr; hor_value < (start_addr + display_length); hor_value += BYTES_PER_PIXEL)
{
*(uint32_t *) (g_p_single_buffer + hor_value) = color;
*(uint32_t *) (g_p_double_buffer + hor_value) = color;
}
start_addr = (uint32_t)(start_addr + (g_hz_size * BYTES_PER_PIXEL));
}
}
static void color_band_display(void)
{
uint16_t color= {RED, GREEN, BLUE, BLACK, WHITE, YELLOW, MAGENTA, CYAN};
uint16_t width = g_vr_size/COLOR_BAND_COUNT;
for (uint8_t display_count = RESET_VALUE; display_count < COLOR_BAND_COUNT; display_count++)
{
screen_display((uint16_t)X1_CO_ORDINATE, (display_count * width), g_hz_size, (uint16_t)(((display_count * width) + width) + INC_DEC_VALUE), color);
}
}
#if BSP_TZ_SECURE_BUILD
FSP_CPP_HEADER
BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ();
/* Trustzone Secure Projects require at least one nonsecure callable function in order to build (Remove this if it is not required to build). */
BSP_CMSE_NONSECURE_ENTRY void template_nonsecure_callable ()
{
}
FSP_CPP_FOOTER
#endif
</code></pre>
<p> </p>
</div><script> var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;" style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
if(parseInt(discuz_uid)==0){
(function($){
var postHeight = getTextHeight(400);
$(".showpostmsg").html($(".showpostmsg").html());
$(".showpostmsg").after(loginstr);
$(".showpostmsg").css({height:postHeight,overflow:"hidden"});
})(jQuery);
} </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script> <div><br />
<br />
代码工程</div>
<p>这测试板比软件更加费劲 </p>
秦天qintian0303 发表于 2024-8-24 10:01
这测试板比软件更加费劲
<p>都难,硬件花时间规划,想啥都加,软件就是要深入去了解。</p>
页:
[1]