找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2998|回复: 5
打印 上一主题 下一主题
收起左侧

Keil环境中怎么替代#pragra

[复制链接]
跳转到指定楼层
楼主
ID:272602 发表于 2019-9-9 18:19 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
88黑币
本帖最后由 thinkingpadcui 于 2019-9-10 16:24 编辑


#pragma location="LCD_region"
char lcd_buffer[8][256];
#pragma location="BG_region"
long lcd_points[8*256*8]
这段代码在IAR下能正常运行,移植到keil5上面就报warning;
keil环境下可以用什么代码代替这四段代码!在线等
gui\LCD\lcd.c(18): warning:  #161-D: unrecognized #pragma
这两个数组应该是定义12864LCD RAM的
void drawPoint(short x, short y, char value)
{
        unsigned short location;

        assert( (x<132));assert((y<64));
        assert( x>=0); assert((y>=0));
        location= y&0x7;
        location +=(y>>3)<<11;
        location += (x<<3);
        lcd_points[location]=value;
}
void paintRect(short x0, short y0, short x1, short y1)
{
        char *pchar;
        char temp_x0;
        y0 =y0>>3;
        y1 =(y1+7)>>3;
        
        for(;y0<=y1;y0++)
        {
                 WriteCommand(0xb0 | (y0));
                WriteCommand(0x10 | (x0>>4));
                WriteCommand(0x0F & (x0));
                WriteCommand(0xE0);
               
                pchar = &lcd_buffer[y0][x0];
                temp_x0=x0;
                for(;temp_x0<=x1;temp_x0++){
                        WriteData(*pchar++);
                }
        }
}这个两个数组只用在这两个函数里面  然后这两个函数被LCD底层驱动函数调用

下面是IAR .icf文件内容  在keil里面 应该怎么实现
#define symbol __ICFEDIT_region_RAM_LCD_start__ = 0x20004000;
#define symbol __ICFEDIT_region_RAM_LCD_end__   = 0x20004FFF;
#define symbol __ICFEDIT_region_RAM_BG_start__  = 0x22080000;
#define symbol __ICFEDIT_region_RAM_BG_end__    = 0x2208FFFF;


#define region LCD_region = mem:[from __ICFEDIT_region_RAM_LCD_start__   to __ICFEDIT_region_RAM_LCD_end__];
#define region BG_region = mem:[from __ICFEDIT_region_RAM_BG_start__   to __ICFEDIT_region_RAM_BG_end__];


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:235200 发表于 2019-9-9 22:17 | 只看该作者
去掉两行,然后
char lcd_buffer[8][256];

long lcd_points[8*256*8];
这两行根据自己的存储器可定义为:
char xdata lcd_buffer[8][256];

long xdata lcd_points[8*256*8];
这样编译就不会出错了
回复

使用道具 举报

板凳
ID:272602 发表于 2019-9-10 12:18 | 只看该作者
csmyldl 发表于 2019-9-9 22:17
去掉两行,然后
char lcd_buffer[8][256];

gui\LCD\lcd.c(18): warning:  #161-D: unrecognized #pragma
这两个数组应该是定义12864LCD RAM的
void drawPoint(short x, short y, char value)
{
        unsigned short location;

        assert( (x<132));assert((y<64));
        assert( x>=0); assert((y>=0));
        location= y&0x7;
        location +=(y>>3)<<11;
        location += (x<<3);
        lcd_points[location]=value;
}
void paintRect(short x0, short y0, short x1, short y1)
{
        char *pchar;
        char temp_x0;
        y0 =y0>>3;
        y1 =(y1+7)>>3;
       
        for(;y0<=y1;y0++)
        {
                 WriteCommand(0xb0 | (y0));
                WriteCommand(0x10 | (x0>>4));
                WriteCommand(0x0F & (x0));
                WriteCommand(0xE0);
               
                pchar = &lcd_buffer[y0][x0];
                temp_x0=x0;
                for(;temp_x0<=x1;temp_x0++){
                        WriteData(*pchar++);
                }
        }
}这个两个数组只用在这两个函数里面  然后这两个函数被LCD底层驱动函数调用
回复

使用道具 举报

地板
ID:272602 发表于 2019-9-10 12:36 | 只看该作者
csmyldl 发表于 2019-9-9 22:17
去掉两行,然后
char lcd_buffer[8][256];

谢谢!不太明白您的意思 我的问题加了补充了  麻烦看一下  谢谢
回复

使用道具 举报

5#
ID:272602 发表于 2019-9-10 22:41 | 只看该作者
看了很多资料问题已解决,下面两行代码完美解决
char lcd_buffer[8][256]__attribute__((at(0x20004000)));

long lcd_points[8*256*8]__attribute__((at(0x22080000)));
回复

使用道具 举报

6#
ID:272602 发表于 2019-9-10 22:42 | 只看该作者
查了很多资料,问题已解决。替换成下面两行代码。完美解决
char lcd_buffer[8][256]__attribute__((at(0x20004000)));

long lcd_points[8*256*8]__attribute__((at(0x22080000)));
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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