problem with arrays in mpc5554 code warrior version 1.5

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

problem with arrays in mpc5554 code warrior version 1.5

3,922 Views
mr_venkatarao
Contributor I
Hi,
i put some values in an array at (initialisation)one location.When i am trying get array values at another location the first element of the array becomes sometimes zero and sometimes correct, other elements are ok.

when i am asigned the first element to some other varible(at initialisaton) ,when i read this variable i am getting correct value always.Indeed i have more array varible in my code but few arrays are behaving like this.some times all array elements make the problem....so please suggest me the solution...
i am using code warrior IDE for MPC5554 controller.
Do i need to modify compiler settings?
 
thanks in advance...
 
 
regards,
venki
Labels (1)
0 Kudos
9 Replies

1,161 Views
mr_venkatarao
Contributor I
Dear voxan,
 
i already submitted technical service request.
 
i am using code warrior version 1.5 for mpc5554.When i am declaring com initialising the array "m" and variable "k" in local only(mean in main routine)then i am getting correct values for both k and m.But when even i declare or initialise them globally the values are going wrong....
 
i am unable to send  settings and etc...it is not permitted for us.....
 
thanks for reply..
 
 
regards,
venki


Message Edited by power pc on 2007-07-16 11:50 AM

Message Edited by power pc on 2007-07-16 11:54 AM
0 Kudos

1,161 Views
Voxan
Contributor III
Venki,

Thanks for creating the SR... somebody should get back to you shortly.

I understand you cannot send any proprietary code out BUT I's just asking for a stationery project which reproduce the behavior you are seing...

Again thanks for your SR.
Regards
0 Kudos

1,161 Views
Voxan
Contributor III
Venki,

attached a project from v1.5 standard stationery, including your code.
I used IOconsole to out put the array values... and it works as expected.
Could you may be modify this one in a way to repro what you are seing and provide it to support guys?

Regards
0 Kudos

1,161 Views
mr_venkatarao
Contributor I
Dear voxan
  
 
              i am really impressed with your response.i have  some queries....Do u get values of k and array m as correct mean "18".  when i simulate the code for two or three iteraration i get corect value(18) after i got zeros and something...do u  try it through serial port?
 
In our company our systems don't have internet....and no drives etc...we cannot copy or anything from our system to net systems..even it is not proprietary code so i am helpless in that matter...
 
 
 
one thing when i get correct values when declaration and intitialisation in main only(local),if one of declaration and intialisation is global then values are in correct..
 
when i am assigning address for k and m i am getting correct
 
here is sample:
unsigned char m[6] : 0x40008000;
unsigned char k :  0x40008100;
 
that means if i am leaving the same(address alocation) for compiler it is behaving differently  am i right?
 
and i am on the way to modify project given by you..
 
anyway thanks for youe response..
 
 
 
regards,
venki 


Message Edited by power pc on 2007-07-17 05:41 AM

Message Edited by power pc on 2007-07-17 05:44 AM

Message Edited by power pc on 2007-07-17 05:49 AM
0 Kudos

1,161 Views
Voxan
Contributor III
Venki,

the provided project is set to use the simulator, as I do not have the HW here.
I did replace your serial output code by printf's to the IO console of thedebugger.

If you run/debug that project you should get the right values for all array items!

based on the same project you can see from the disassembly file that the compiler will place both K and M into the .sbss memory section, for uninitialized objects.

So I would guess your project is not using the exact same code you sent...

Hope this helps...

Regards
0 Kudos

1,161 Views
mr_venkatarao
Contributor I
Dear voxan,
  thanks for your reply...i did select axiom  board project building....now i selcted full chip configaration...after reading your msg i tried with simulator option ...now it is working.....
thanks for your help....
 
 
still i have problem of first element of array becomes sometimes zero.......i trying to clear it....and onething i just found onething in confg group files,  MPC5554.cfg file is missed ..is it cause for so?at  present i can't test because of not availabilty HW..i will test it  with in a 1 week...
anyway once again thanks for your help.
regards,
venki
0 Kudos

1,161 Views
johncoleman
Contributor IV

I see POKY and TCF-AGENT running on the Board, but I can not login.

Starting syslogd/klogd: done

Starting tcf-agent: OK

Poky (Yocto Project Reference Distro) 1.8 imx6ulevk /dev/ttymxc0

imx6ulevk login: root

Login incorrect

I also can not successfully connect through the Eclipse RunConfig, I just get a NO ROUTE Error.

0 Kudos

1,161 Views
Voxan
Contributor III
Hi Venki,

we would need some more details on your source code and the project settings. The best way being that you submit a reproducible to the support line at

http://www.freescale.com/webapp/sps/site/homepage.jsp?nodeId=054670&tid=FSH

and click the "Submit a service request".

Note: the current version of CW 55xx is v2.1. Please be aware that there is NO debugger included since v2.0
The debuggers come from partners as Lauterbach, iSystem...

Hope this helps...

Regards
0 Kudos

1,161 Views
mr_venkatarao
Contributor I
Dear VOXAN,
    
        I have found a similar kind of problem, when i declared a global array of size 6 and a global variable k  and tried to assign the k value to that array in the main routine before  while(1)  and send the array values to the serial port (in polling method)  continuously...It was observed that the array values and the k value were changing in undefined pattern.  Moreover i have not made any changes in the project settings.
 
When the same array and the variable k was declared as local...then the array values were initialized to the assigned values.
 
Here i am sending that code.
 
#include "mpc5554.h"
 
unsigned char m[6], k ;
 
void Send_data_2port(unsigned char sdata)
{
ESCI_A.DR.R=sdata;
while(ESCI_A.SR.B.TDRE==0)
{
}
ESCI_A.SR.B.TC=1;
ESCI_A.SR.B.TDRE=1;
}
 
void sport_initialise(void)
{
SIU.PCR[89].R=0X400;
SIU.PCR[90].R=0X400;
ESCI_A.CR1.R=0X00680006;
ESCI_A.CR2.R=0;
 
while(ESCI_A.SR.B.TDRE==0)
{    }
ESCI_A.SR.B.TC =1;
ESCI_A.SR.B.TDRE =1;
}
 
 
void main()
{
 unsigned int i;
sport_initialise();   //9600 baud rate for clock frequency 16Mhz
k=18;
 
for(i=0;i<6;i++)
   m[i]=k;
 
while(1)
{
Send_data_2port(k);
 
for(i=0;i<6;i++)
 Send_data_2port(m[i]);
 
}
 
 
 
i am unable to find the proper reason why this happening...Any global variable which has been initialized to a value should retain that value unless it is overwritten..but this not he case here.. I have seen the linker map file and found that the array was assigned an external memory address
0x3ff81348 for k and 0x3ff81350 for the array m.
 
Awaiting for your quick response.
 
Regards,
Venki
0 Kudos