|
|
View previous topic :: View next topic |
Author |
Message |
Orcino
Joined: 07 Sep 2003 Posts: 56
|
Vector passed as parameter to a function |
Posted: Tue Dec 06, 2016 1:05 pm |
|
|
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
|
|
Posted: Tue Dec 06, 2016 1:22 pm |
|
|
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
|
|
Posted: Tue Dec 06, 2016 2:29 pm |
|
|
Very, very thanks Ttelmah
This code " memset(XBEE_RX.payLoad,0,bufferRX_XBEE-1); " was causing problems.
Orcino |
|
|
|
|
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
|