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

Reading of const-array (2-dim) with PCH 3.202, Opt-9

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







Reading of const-array (2-dim) with PCH 3.202, Opt-9
PostPosted: Fri Jun 25, 2004 3:54 am     Reply with quote

Hello together,

during compiler-update (3.189 -> 3.202) one of a function creates
troubles:

byte const CAN_SPEED[4][5] =
{
// BRG, SYNC, PROP, PH1, PH2
{ 0, 0, 0, 3, 3}, // 1 MBit -> 30m (10 Tq)
{ 1, 0, 0, 3, 3}, // 500 kBit -> 100m (10 Tq)
{ 4, 0, 2, 5, 5}, // 125 kBit -> 500m (16 Tq)
{ 9, 0, 2, 5, 5} // 62,5 kBit -> 1000m (16 Tq)
};

void can_set_baud(byte b_nr) {
byte a;
b_nr = 0;
a =CAN_SPEED[b_nr][0]; // a=3 ? should be 0
a =CAN_SPEED[b_nr][1]; // a=1 ? should be 0
a =CAN_SPEED[b_nr][2]; // a=0 ? should be 0
a =CAN_SPEED[b_nr][3]; // a=0 ? should be 3
a =CAN_SPEED[b_nr][4]; // a=3 ? should be 3
b_nr=1;
a =CAN_SPEED[b_nr][0]; // a=3 ? should be 1
a =CAN_SPEED[b_nr][1]; // a=4 ? should be 0
a =CAN_SPEED[b_nr][2]; // a=0 ? should be 0
a =CAN_SPEED[b_nr][3]; // a=2 ? should be 3
a =CAN_SPEED[b_nr][4]; // a=5 ? should be 3
b_nr=2;
a =CAN_SPEED[b_nr][0]; // a=5 ? should be 4
a =CAN_SPEED[b_nr][1]; // a=9 ? should be 0
a =CAN_SPEED[b_nr][2]; // a=0 ? should be 2
a =CAN_SPEED[b_nr][3]; // a=2 ? should be 5
a =CAN_SPEED[b_nr][4]; // a=5 ? should be 5
b_nr=3;
a =CAN_SPEED[b_nr][0]; // a=5 ? should be 9
a =CAN_SPEED[b_nr][1]; // a=f2 ? should be 0
a =CAN_SPEED[b_nr][2]; // a=cf ? should be 2
a =CAN_SPEED[b_nr][3]; // a=0e ? should be 5
a =CAN_SPEED[b_nr][4]; // a=f0 ? should be 5
}

The reading of the const-array doesn't works.
Has someone found the same ?
If I use OPT-8 (+Y=8) it works correctly ????


UKH
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Fri Jun 25, 2004 4:59 am     Reply with quote

Did the same code work correctly under 3.189?

If you look at the pattern of the data you are getting in the variable a, it is obvious that the compiler is skipping the first four bytes of your array and treating the fifth byte as the first. And that is also the reason why your last four readings are totally wrong.
UKH
Guest







Reading of const-array (2-dim) with PCH 3.202, Opt-9
PostPosted: Fri Jun 25, 2004 5:34 am     Reply with quote

Yes, same works with 3.189.

UKH
jventerprises



Joined: 01 Apr 2004
Posts: 43
Location: Boston

View user's profile Send private message Visit poster's website

const array
PostPosted: Mon Jun 28, 2004 10:11 am     Reply with quote

i found that i could not use ICD and look at any values in the const array, but when i ran the code, it worked just fine. i could not step over the code that used the CONST, though.

i suspect it has to do with the compiler actually replacing these values at compile time, so they dont actually exist.
_________________
Jon
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Mon Jun 28, 2004 6:04 pm     Reply with quote

Yes, that is because the compiler implements a look-up table with RETLWs for constant arrays. It doesn't store the actual values in the memory.
UKH
Guest







Reading of const-array (2-dim) with PCH 3.202, Opt-9
PostPosted: Tue Jun 29, 2004 1:31 am     Reply with quote

Yesterday I've passed my problem to CCS. Currently I turned back to version 3.189 which works fine in this case.
UKH
Guest







Bug was confirmed by CCS
PostPosted: Wed Jun 30, 2004 11:58 pm     Reply with quote

Bug was confirmed and will be fixed in 3.203

UKH
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