CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

read_program_eeprom problem with big table!!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cagacug



Joined: 14 Apr 2004
Posts: 5

View user's profile Send private message

read_program_eeprom problem with big table!!
PostPosted: Wed Apr 14, 2004 4:18 pm     Reply with quote

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!!
PostPosted: Wed Apr 14, 2004 4:28 pm     Reply with quote

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

View user's profile Send private message

read_program_eeprom problem
PostPosted: Thu Apr 15, 2004 12:10 am     Reply with quote

Thank you very much , that is the exact problem, and solved.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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