野火电子论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 9880|回复: 1

我参考了从SD卡读字库的例程但是总是在一个地方出现硬件错误帮忙,看看

[复制链接]
发表于 2018-9-6 11:12:00 | 显示全部楼层 |阅读模式
void LCD_DispChar_CH ( uint16_t usX, uint16_t usY, uint16_t usChar)
{
    uint8_t ucPage, ucColumn;
    uint8_t ucBuffer [ 24*24/8 ];       

    uint32_t usTemp;        


    uint32_t  xpos =0;
    uint32_t  Xaddress = 0;
    if(Ltdc_Handler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
    { /* RGB565 format */
        /*xpos表示当前行的显存偏移位置*/
        xpos = usX*XSIZE_PHYS*2;
    }
    else
    { /* ARGB8888 format */
        /*xpos表示当前行的显存偏移位置*/
        xpos = usX*XSIZE_PHYS*4;
    }


    /*Xaddress表示像素点*/
    Xaddress += usY;

    macGetGBKCode ( ucBuffer, usChar );        //取字模数据

    /*ucPage表示当前行数*/
    for ( ucPage = 0; ucPage < macHEIGHT_CH_CHAR; ucPage ++ )
    {
        /* 取出3个字节的数据,在lcd上即是一个汉字的一行 */
        usTemp = ucBuffer [ ucPage * 3 ];
        usTemp = ( usTemp << 8 );
        usTemp |= ucBuffer [ ucPage * 3 + 1 ];
        usTemp = ( usTemp << 8 );
        usTemp |= ucBuffer [ ucPage * 3 + 2];


        for ( ucColumn = 0; ucColumn < macWIDTH_CH_CHAR; ucColumn ++ )
        {                       
            if ( usTemp & ( 0x01 << 23 ) )  //高位在前         (每次都在这里出现硬件错误)                       
            {         
              if(Ltdc_Handler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
              { /* RGB565 format */
                //字体色
                /* Write data value to all SDRAM memory */
                *(__IO uint16_t*) (Ltdc_Handler.LayerCfg[ActiveLayer].FBStartAdress + (2*Xaddress) + xpos) = DrawProp[ActiveLayer].TextColor;
              }
              else
              { /* ARGB8888 format */
                //字体色
                /* Write data value to all SDRAM memory */
                *(__IO uint32_t*) (Ltdc_Handler.LayerCfg[ActiveLayer].FBStartAdress + (4*Xaddress) + xpos) = DrawProp[ActiveLayer].TextColor;
              }

            }                               
            else       
            {
                //背景色
              /* Write data value to all SDRAM memory */
             if(Ltdc_Handler.LayerCfg[ActiveLayer].PixelFormat == LTDC_PIXEL_FORMAT_RGB565)
              { /* RGB565 format */
                //字体色
                /* Write data value to all SDRAM memory */
                *(__IO uint16_t*) (Ltdc_Handler.LayerCfg[ActiveLayer].FBStartAdress + (2*Xaddress) + xpos) = DrawProp[ActiveLayer].BackColor;
              }
              else
              { /* ARGB8888 format */
                //字体色
                /* Write data value to all SDRAM memory */
                *(__IO uint32_t*) (Ltdc_Handler.LayerCfg[ActiveLayer].FBStartAdress + (4*Xaddress) + xpos) = DrawProp[ActiveLayer].BackColor;
              }
            }       
            /*指向当前行的下一个点*/       
            Xaddress++;                       
            usTemp <<= 1;

        }
        /*显示完一行*/
        /*指向字符显示矩阵下一行的第一个像素点*/
        Xaddress += (XSIZE_PHYS - macWIDTH_CH_CHAR);

    }
}


回复

使用道具 举报

 楼主| 发表于 2018-9-6 11:17:49 | 显示全部楼层
LTDC—LCD显示汉字(字库在SD卡)这个例程,746的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

联系站长|手机版|野火电子官网|野火淘宝店铺|野火电子论坛 ( 粤ICP备14069197号 ) 大学生ARM嵌入式2群

GMT+8, 2024-4-24 07:40 , Processed in 0.035087 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表