液晶N5110 驱动 编译常量不能读出? PROGMEM const内详
本帖最后由 wmsky 于 2013-7-21 11:05 编辑历史,上一贴,想把89s52 的keil 程序转为AVR M8这么难啊
http://www.amobbs.com/thread-5542767-1-1.html
解决了 IO转换问题 和include 问题
编译环境 Atmel studio 6.1
新的问题,定义在Flash里显示不正常
PROGMEM constunsigned char Font_code[] = {
{0x00,0x00,0x00,0x00,0x00,0x00},// (0)
{0x00,0x00,0x00,0x4F,0x00,0x00},//!(1)
定义在内存里显示是正常
unsigned char Font_code[] = {
{0x00,0x00,0x00,0x00,0x00,0x00},// (0)
{0x00,0x00,0x00,0x4F,0x00,0x00},//!(1)
定义在flash中的数组要用pgm_read_byte()读出~~~ elsonx 发表于 2013-7-21 11:51 static/image/common/back.gif
定义在flash中的数组要用pgm_read_byte()读出~~~
谢谢,回复,好像见过这个,我试试
本帖最后由 wmsky 于 2013-7-21 16:46 编辑
elsonx 发表于 2013-7-21 11:51 static/image/common/back.gif
定义在flash中的数组要用pgm_read_byte()读出~~~
void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat)
{
unsigned char i;
c_dat -=32 ; //查表
x *= 6; //宽6
LCD_pos_byte(x, y); //坐标
for(i = 0; i < 6; i++)
LCD_write_dat(Font_code [ i ]) ;///
}//
还是不会,请教上面函数怎么改才行呢?
//
wmsky 发表于 2013-7-21 13:37 static/image/common/back.gif
void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat)
{
unsigned char i;
LCD_write_dat(pgm_read_byte(Font_code)); 本帖最后由 wmsky 于 2013-7-21 19:15 编辑
elsonx 发表于 2013-7-21 16:21 static/image/common/back.gif
LCD_write_dat(pgm_read_byte(Font_code));
谢谢你。看了好多例子都不行,好晕,换回AVR studio 4试试 礼拜一了,顶一顶,继续求解 开一个缓冲区 先把FLASH内的数据prog_read_byte读出来到缓冲区 再把缓冲区的数据写进LCD这样应该可以了吧 本帖最后由 wmsky 于 2013-7-23 11:19 编辑
yklstudent 发表于 2013-7-22 23:30 static/image/common/back.gif
开一个缓冲区 先把FLASH内的数据prog_read_byte读出来到缓冲区 再把缓冲区的数据写进LCD这样应该可以了吧 ...
谢谢,试了还是不行,用的是Atmel studio6.1的编译。
中间用了
学习进程卡在这个点上了,
/*--------------------------------------------------------------*/
//液晶字符输出(6*8字体)
//x: 0 - 13
//y: 0 - 5
void LCD_printc(unsigned char x, unsigned char y, unsigned char c_dat)
{
unsigned char i;
unsigned char a; //debug
c_dat -=32 ; //查表
x *= 6; //宽6
LCD_pos_byte(x, y); //坐标
for(i = 0; i < 6; i++)
//LCD_write_dat(Font_code [ i ] );
a=prog_read_byte(Font_code [ i ] ); //prog_read_byte(&(Font_code [ i ] )); //debug
LCD_write_dat(a);
} 问题解决了
参考了E文help。
Optimization 优化改为 none(-00)
LCD_write_dat(Font_code) ;改为:
LCD_write_dat(pgm_read_byte(&(Font_code [ i ]))) ;
常量文件定义:
PROGMEM const unsigned char Font_code[] = {
{0x00,0x00,0x00,0x00,0x00,0x00},// (0)
{0x00,0x00,0x00,0x4F,0x00,0x00},//!(1)
同时再谢谢上面各位的回复。
页:
[1]