给先楫HPM6750EVKMINI画一个LCD扩展板(上电调试)
<p> HPM6750EVKMINI的LCD扩展板弄好了,有点小问题不过还算比较顺利,先来看一下效果。</p><p>2c8834a344946a82b95297f2013ad7fe</p>
<p> 最初画的板子因为线宽设计的是3.5mil 2层板JLC那边达不到这个工艺,后来使用6mil重画,因为JLC提交文件就会占用一次免费名额,本着能白嫖就不花钱的原则我又到HQPCB那边免费打了个板。</p>
<p> 这个板子LCD接口在上边,屏幕通过排线折叠后安装在下边,当时忘了给排线开槽,导致排线只能从板子边缘折过来,为此将右边PCB磨掉了几毫米。该说不说PQPCB的质量真不是一搬的好,磨了半天。</p>
<p></p>
<p> 另一个问题是背面和HPM6750EVKMINI连接的FPC排线座画的靠左了,会支起屏幕,效果不是很好,不过整体焊接很成功。上图的屏幕连接器之前手焊要焊很多次,这次买了小尖头烙铁一次成功。</p>
<p> 测试使用sdk_env_v0.10.0\hpm_sdk\samples\drivers\lcdc的例程,重定义了复位引脚和软SPI配置引脚。</p>
<pre>
<code class="language-cpp">#define LCD_CS_GPIO_BASE BOARD_LCD_POWER_GPIO_BASE
#define LCD_CS_GPIO_INDEX BOARD_LCD_POWER_GPIO_INDEX
#define LCD_CS_GPIO_PIN BOARD_LCD_POWER_GPIO_PIN
#define LCD_RST_GPIO_BASE BOARD_CAP_RST_GPIO
#define LCD_RST_GPIO_INDEX BOARD_CAP_RST_GPIO_INDEX
#define LCD_RST_GPIO_PIN BOARD_CAP_RST_GPIO_PIN
#define LCD_SDA_GPIO_BASE HPM_GPIO0
#define LCD_SDA_GPIO_INDEX BOARD_CAP_I2C_SDA_GPIO_INDEX
#define LCD_SDA_GPIO_PIN BOARD_CAP_I2C_SDA_GPIO_PIN
#define LCD_SCL_GPIO_BASE HPM_GPIO0
#define LCD_SCL_GPIO_INDEX BOARD_CAP_I2C_CLK_GPIO_INDEX
#define LCD_SCL_GPIO_PIN BOARD_CAP_I2C_CLK_GPIO_PIN
</code></pre>
<p>增加了一些软SPI相关的函数,这里的hal_delay_us1是一个大致的延时。</p>
<pre>
<code class="language-cpp">uint16_t auo_cmd[] = {
0x0A03,
0x01F8,
0x0B77,
0x0CCC,
0x0DCC,
0x0EAC,
0x0F8A,
0x100A,
0x11CC,
0x12CC,
0x13AC,
0x148A,
0x150A,
0x16CC,
0x17CC,
0x18AC,
0x198A,
0x1A0A
};
void lcd_rst_output(uint8_t level)
{
gpio_write_pin(LCD_RST_GPIO_BASE, BOARD_CAP_RST_GPIO_INDEX,LCD_RST_GPIO_PIN, level);
}
void lcd_cs_output(uint8_t level)
{
gpio_write_pin(LCD_CS_GPIO_BASE, LCD_CS_GPIO_INDEX,LCD_CS_GPIO_PIN, level);
}
void lcd_scl_output(uint8_t level)
{
gpio_write_pin(LCD_SCL_GPIO_BASE, LCD_SCL_GPIO_INDEX,LCD_SCL_GPIO_PIN, level);
}
void lcd_sda_output(uint8_t level)
{
gpio_write_pin(LCD_SDA_GPIO_BASE, LCD_SDA_GPIO_INDEX,LCD_SDA_GPIO_PIN, level);
}
void hal_delay_us1(uint16_t delay)
{
uint32_t i,j;
for(i=0;i<delay;i++)
for(j=0;j<10000;j++);
}
void lcd_gpio_init(void)
{
gpio_enable_pin_output_with_initial(LCD_RST_GPIO_BASE, BOARD_CAP_RST_GPIO_INDEX,LCD_RST_GPIO_PIN, 0);
gpio_enable_pin_output_with_initial(LCD_CS_GPIO_BASE, LCD_CS_GPIO_INDEX,LCD_CS_GPIO_PIN, 1);
gpio_enable_pin_output_with_initial(LCD_SCL_GPIO_BASE, LCD_SCL_GPIO_INDEX,LCD_SCL_GPIO_PIN, 0);
gpio_enable_pin_output_with_initial(LCD_SDA_GPIO_BASE, LCD_SDA_GPIO_INDEX,LCD_SDA_GPIO_PIN, 0);
}
void soft_spi_write_16bit(uint16_t tx_byte)
{
unsigned char i;
lcd_scl_output(0);
hal_delay_us1(1);
for(i=0;i<16;i++)
{
if(0x8000&tx_byte)
{
lcd_sda_output(1);
}
else
{
lcd_sda_output(0);
}
tx_byte<<=1;
lcd_scl_output(1);
hal_delay_us1(1);
lcd_scl_output(0);
hal_delay_us1(1);
}
lcd_scl_output(0);
hal_delay_us1(1);
}
void lcd_init(void)
{
uint8_t i;
lcd_gpio_init();
//
board_delay_ms(1000);
lcd_rst_output(1);
lcd_rst_output(0);
board_delay_ms(2);
lcd_rst_output(1);
board_delay_ms(500);
for(i=0;i<18;i++)
{
lcd_cs_output(0);
hal_delay_us1(1);
soft_spi_write_16bit(auo_cmd);
hal_delay_us1(1);
lcd_cs_output(1);
hal_delay_us1(1);
}
}</code></pre>
<p> 为了和我的屏幕适配,修改了lcdc_get_default_config里的一些参数。</p>
<pre>
<code class="language-cpp">void lcdc_get_default_config(LCDC_Type *ptr, lcdc_config_t *config)
{
config->resolution_x = 640;
config->resolution_y = 480;
config->hsync.front_porch_pulse = 41;
config->hsync.back_porch_pulse = 41;
config->hsync.pulse_width = 40;
config->vsync.front_porch_pulse = 18;
config->vsync.back_porch_pulse = 18;
config->vsync.pulse_width = 9;
config->background.u = 0x0;
config->control.display_mode = lcdc_display_mode_normal;
config->control.line_pattern = lcdc_line_pattern_rgb;
config->control.invert_pixel_clock = false;
config->control.invert_pixel_data = false;
config->control.invert_href = false;
config->control.invert_vsync = false;
config->control.invert_hsync = false;
}</code></pre>
<p> 调整了board_init_lcd_clock里的分频值,将原来的29.7MHz改成了23.7MHz。</p>
<pre>
<code class="language-cpp">uint32_t board_init_lcd_clock(void)
{
uint32_t freq;
clock_add_to_group(clock_display, 0);
/* Configure LCDC clock to 23.7MHz */
clock_set_source_divider(clock_display, clock_source_pll4_clk0, 25U);
freq = clock_get_frequency(clock_display);
return freq;
}</code></pre>
<p>将board.h里的800*480修改为640*480。</p>
<pre>
<code class="language-cpp">/* lcd section */
#ifndef BOARD_LCD_WIDTH
#define BOARD_LCD_WIDTH (640)
#endif
#ifndef BOARD_LCD_HEIGHT
#define BOARD_LCD_HEIGHT (480)
#endif</code></pre>
<p>以上操作后下载、运行,屏幕就亮起来了。</p>
<p>这个一漂浮,到边缘就离开这个效果,好像windows的那个泡泡保护屏效果</p>
<p>还是虾哥厉害。</p>
<p>这动手能力杠杠的!</p>
<p>厉害啊</p>
<p><img height="48" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/wanwan88.gif" width="59" /></p>
<p><img height="48" src="https://bbs.eeworld.com.cn/static/editor/plugins/hkemoji/sticker/facebook/wanwan76.gif" width="48" /></p>
页:
[1]