|
|
View previous topic :: View next topic |
Author |
Message |
UKH Guest
|
Reading of const-array (2-dim) with PCH 3.202, Opt-9 |
Posted: Fri Jun 25, 2004 3:54 am |
|
|
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
|
|
Posted: Fri Jun 25, 2004 4:59 am |
|
|
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 |
Posted: Fri Jun 25, 2004 5:34 am |
|
|
Yes, same works with 3.189.
UKH |
|
|
jventerprises
Joined: 01 Apr 2004 Posts: 43 Location: Boston
|
const array |
Posted: Mon Jun 28, 2004 10:11 am |
|
|
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
|
|
Posted: Mon Jun 28, 2004 6:04 pm |
|
|
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 |
Posted: Tue Jun 29, 2004 1:31 am |
|
|
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 |
Posted: Wed Jun 30, 2004 11:58 pm |
|
|
Bug was confirmed and will be fixed in 3.203
UKH |
|
|
|
|
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
|