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

Vector passed as parameter to a function

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



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

Vector passed as parameter to a function
PostPosted: Tue Dec 06, 2016 1:05 pm     Reply with quote

Hi,

The code below works twice. Then the vector passed as parameter is empty.

Can anyone help?

Thank you
Orcino




Code:


void mostraDisplay(unsigned int8 vetorImagem[]);

//=============================================
unsigned int8   falha_s1[17]    = {0xF1, 0x0F, 0x00, 0xAC, 0x00, 0x98, 0x01, 0x70, 0x01, 0x05, 0x05, 0x19, 0x23, 0x20, 0x19, 0x35, 0xF4};
unsigned int8   falha_s2[17]    = {0xF1, 0x0F, 0x00, 0xAC, 0x01, 0xA0, 0x01, 0x70, 0x00, 0x05, 0x05, 0x19, 0x23, 0x20, 0x19, 0x3D, 0xF4};

unsigned int8   ok_s1[17]       = {0xF1, 0x0F, 0x00, 0xAC, 0x00, 0x98, 0x01, 0x70, 0x01, 0x05, 0x0B, 0x22, 0x32, 0x33, 0x32, 0x7F, 0xF4};
unsigned int8   ok_s2[17]       = {0xF1, 0x0F, 0x00, 0xAC, 0x01, 0xA0, 0x01, 0x70, 0x01, 0x05, 0x0B, 0x22, 0x32, 0x33, 0x32, 0x88, 0xF4};

//==============================================

void teste(void)
{
if(contTime_6_horas == 100 )   
             {                           
             if(flagRecebeuDadosSensor_1==1)
                        mostraDisplay(ok_s1); 
           
                  else
                     mostraDisplay(falha_s1);    // <=============         
                     
                   
              if(flagRecebeuDadosSensor_2==1)
                       mostraDisplay(ok_s2); 
           
                    else
                       mostraDisplay(falha_s2);  // <==========
           
             contTime_6_horas=0;  /
             } 
  }

//==============================================
void mostraDisplay(unsigned int8 vetorImagem[])
{
    unsigned int8 cont=0;
 
    for(cont=0;cont < 50; cont++)
         {     
         fputc(vetorImagem[cont],DISPLAY);
         
        if(vetorImagem[cont]==0xF4)
             {
             break;
             }
         }
 
   return;
}               
[
Ttelmah



Joined: 11 Mar 2010
Posts: 19510

View user's profile Send private message

PostPosted: Tue Dec 06, 2016 1:22 pm     Reply with quote

It's almost certainly something else in the code. Somewhere in the stuff that calls this routine, some other code perhaps accessing an array is walking over the end of where it should access, and is overwriting the stored data.

Look in the .sym file, and find the variables that are just below these arrays in memory. Then look carefully at the code that accesses these.
Look at block routines like memcpy, anything accessing an array especially pointer operations), and particularly string functions (remember these often won't stop till they get to a '\0'). Add some debugging tests to check the offsets being used when you access these.

If these arrays are 'fixed' (never going to be changed by your code), you could declare them as 'const', and add #device PASS_STRINGS=IN_RAM, so they won't get overwritten, and to save RAM. However you really must find the problem first (otherwise it's a problem waiting to happen).
Orcino



Joined: 07 Sep 2003
Posts: 56

View user's profile Send private message

PostPosted: Tue Dec 06, 2016 2:29 pm     Reply with quote

Very, very thanks Ttelmah

This code " memset(XBEE_RX.payLoad,0,bufferRX_XBEE-1); " was causing problems.

Orcino
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