Reading wrong LUT value

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Reading wrong LUT value

Post by medelec35 »

Not put this in bugs since it could be my mistake.
I have variable called ADC0 which is assigned to AN0. Value of AN0 is divided by 5 so 0 - 255 = 0 to 51 so that means LUT from pos 0 to pos 51 will be read.
all Lut (pos 0 to 50 ) are read ok. Problem is for some reason if looking up the value of pos 51 LUT, then the look-up table of a different Variable is always returned.
eg if got

Code: Select all

rom char* std155_rpmf1 = 
{
117,122,127,132,137,142,146,149,152,155,158,160,163,166,169,172,174,177,180,183,186,189,192,195,198,201,204,207,209,212,215,218,222,226,229,233,236,240,244,247,251,254,26,26,26,26,27,27,27,27,28
};
rom char* std155_rpmf2 = 
{
108,110,115,120,125,130,134,137,140,143,146,148,151,154,157,160,162,165,168,171,174,177,180,183,186,189,192,195,197,200,203,206,210,214,217,221,224,228,232,235,239,242,246,246,248,250,254,26,26,26,26
};
and ADC0=50 then correct value of 27 is retrieved.
If ADC0=51 then the next look-up value table is retrieved in this case 108 is retrieved.
Even if I add more numbers on to the end of rom char* std155_rpmf1, 108 is still retrieved.
I have followed ASM in a simulator and for some reason when ADC0 is 51, W reg which is moved to PCL makes the PC jump to label of rom char* std155_rpmf2 hence retrieving the first value, instead of pointing to pos 51.
Any ideas why please or even how to solve this issue?
Thank you
Attachments
LUT Problem.fcf
(57.45 KiB) Downloaded 275 times
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading wrong LUT value

Post by Benj »

Hi Medelec

Thats an odd one. Have you tried referencing the lookup table data directly in a smaller cut down program.

Eg just have your look up tables and then do something like,

FCV_TEMP = std155_rpmf1[51];

LCD_Print_Number(temp)

Just to make sure all the calculations etc are working as they should.

It could also be that the ROM is being corrupted due to space limitations, though you should get a warning when you compile if this is the case.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Reading wrong LUT value

Post by medelec35 »

Thanks Ben. Its now sorted. 8) I'm glad I said it may not be a bug, I did make a couple of mistakes and flowcode is totally blameless.
I use excel to automatically put all the look-up tables in the supplementary code window. I made one mistake, so instead of placing 51 numbers, only 50 were placed (although 51 was shown in the column). So If your LUT is short, it will read form the next one (if more than one LUT)
But the silly thing is when I added more numbers to LUT since there are a total of 8 LUT's I added to wrong one :oops:
Well I have been over worked recently (That's My excuse and I'm sticking to it :P )
Martin

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Reading wrong LUT value

Post by Benj »

Sounds like a good excuse to me :mrgreen: Glad you got it all sorted in the end though :)

Post Reply