memcpy problem wit CV please advise

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Freaks
I am using the TK500 and the ICE200 with code vision cmpiler

In my applicatio i am selecting a random number between 1 to 16.
According to the number that it selects...I am loading an array using the case command.

This is part of the code

int balance[7]={1124,1080,1686,1080,1122,1602,1608};
int camera[6]={1602,1080,1652,1608,1626,1080};

switch (random_massage)
{
case 1:
memcpy(data_base_holder,balance,sizeof (int)*7);
break;
case 2:
memcpy(data_base_holder,camera,sizeof (int)*6);
break;

So if the random massage is 1 then the Balace numbers will be loaded to an array called data_base_holder.

It is working fine for all the 15 numbers accept for the case 1 selection.
What i mean is...as soon as i turn on the system and lets say that the first number that is selected is number 1 then the right array will be loaded
The problem accures if the random_massae is "1" but not at the first time.
What happens is that insted of loading the whole numbers ...it loads the first letter as "0" and the rest of the numbers are ok.
This thing is cositentic and i dont know why it happens

Please advise

Thnak you

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi

Try to add a breakpoint when "data_base_holder[0]" is written, you probably overwrite the location with zero somewhere else in the program. Alternatively balance[0] is overwritten with zero.

Ps. in most cases a search in an editor solves the problem faster. You may also have an array just before balance, which is written past its end.

Erik