|
|
View previous topic :: View next topic |
Author |
Message |
cagacug
Joined: 14 Apr 2004 Posts: 5
|
read_program_eeprom problem with big table!! |
Posted: Wed Apr 14, 2004 4:18 pm |
|
|
Hi to All,
Classical read rom problem!!
Using PIC 16f877, compiler v 3.184.
I have a big lookup table in the rom which I insert it with #ORG and #ROM instructions. The table contains appr. 1300 bytes starting from adress 0x1800.
I read the data with "read_program_eeprom", I use the exact code like this :
temp1 = read_program_eeprom (0x1800 + (cur_chr*5) + cur_col - 1);
which works fine for the first 256 items, but gives unexpected values for the rest. When I change the starting adress of the ROM to something like :
temp1 = read_program_eeprom (0x1900 + (cur_chr*5) + cur_col - 1);
again works for another 256 items but gives unexpected results for the rest. I also tried putting all the adress data to a long variable and then calling the function like:
long adres;
adres = 0x1900 + (cur_chr*5) + cur_col - 1;
temp1 = read_program_eeprom (adres);
, it didnt work.
Anyone have an idea?
Thanks |
|
|
Ttelmah Guest
|
Re: read_program_eeprom problem with big table!! |
Posted: Wed Apr 14, 2004 4:28 pm |
|
|
cagacug wrote: | Hi to All,
Classical read rom problem!!
Using PIC 16f877, compiler v 3.184.
I have a big lookup table in the rom which I insert it with #ORG and #ROM instructions. The table contains appr. 1300 bytes starting from adress 0x1800.
I read the data with "read_program_eeprom", I use the exact code like this :
temp1 = read_program_eeprom (0x1800 + (cur_chr*5) + cur_col - 1);
which works fine for the first 256 items, but gives unexpected values for the rest. When I change the starting adress of the ROM to something like :
temp1 = read_program_eeprom (0x1900 + (cur_chr*5) + cur_col - 1);
again works for another 256 items but gives unexpected results for the rest. I also tried putting all the adress data to a long variable and then calling the function like:
long adres;
adres = 0x1900 + (cur_chr*5) + cur_col - 1;
temp1 = read_program_eeprom (adres);
, it didnt work.
Anyone have an idea?
Thanks |
If 'cur_chr' or 'chr_col', are integers, remember the actual arithmetic used for the calculations will only be 8bit. Try with:
adres = 0x1900L + ((int16)cur_chr*5) + ((int16)cur_col - 1);
CCS C, does not 'promote forward' types. On most C compilers, if one part of the arithmetic is a 'long', all the arithmetic will be long. On the CCS C, instead only the parts containing a long will be performed using long arithmetic. This saves space, but means you must be aware to 'cast' up when needed.
Best Wishes |
|
|
cagacug
Joined: 14 Apr 2004 Posts: 5
|
read_program_eeprom problem |
Posted: Thu Apr 15, 2004 12:10 am |
|
|
Thank you very much , that is the exact problem, and solved. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|