Keil™, An ARM® Company

Discussion Forum

Inicialize struct

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
javi pks
Posted
15-May-2008 05:19
Toolset
C51
New! Inicialize struct

HI!!

I'm initalization 3 global variables type struct in main.c
This struct is defined in PID.h :

typedef struct {

int dState;             /* Last position input */
int iState;                 /* Integrator State    */
int iMax,iMin;      /* Maximum and Minimun allowable integrator state               */
int pGain, iGain, dGain;                /* integral, proportional & derivative  gain       */
}SPid ;

Is it correct to do it??:

SPid iA = {0,0,10000,-10000,1,1,0};
SPid iB = {0,0,10000,-10000,1,1,0};
SPid iC = {0,0,10000,-10000,1,1,0};

because my program work so well without this initialization but i need it for to do other task.

Read-Only
Author
Per Westermark
Posted
15-May-2008 05:28
Toolset
C51
New! RE: Inicialize struct

Do you have any reason to believe that there is anything wrong with your declaration, or exactly what are you asking?

Do the compiler accept your code without any compilation error?

Do the variables get their expected values?

Read-Only
Author
javi pks
Posted
15-May-2008 07:12
Toolset
C51
New! RE: Inicialize struct

The compiler work ok, but a task dont work correctly.
This task no uses that variables but if that var is comment then work well.
I dont know why.

Some idea??

Read-Only
Author
Hans-Bernhard Broeker
Posted
15-May-2008 15:25
Toolset
C51
New! RE: Inicialize struct

I dont know why.

Neither does anybody else. How could we, without so much as a hint of an idea what this "task" is, nor what it's supposed to do?

Read-Only
Author
javi pks
Posted
16-May-2008 01:38
Toolset
C51
New! RE: Inicialize struct

Thanks for your reply.

When i start my program and it's simulated by uVision, in the UART i can see 6 variables that my tasks send to serial port. But when i run this program under target board EMP900 + MCB900 (emulator + evaluation board), in my hiperterminal i canÂ't see that variables.

Some idea??

Read-Only
Author
Per Westermark
Posted
16-May-2008 03:14
Toolset
C51
New! RE: Inicialize struct

Can you see variables with the wrong contents, or no text at all?

If you can't see any text at all, you shouldn't think about problems with the variables, but problems with your UART code. The simulator isn't absolutely 100% perfect.

Read-Only
Author
Per Westermark
Posted
16-May-2008 03:24
Toolset
C51
New! RE: Inicialize struct

And of course: If the output looks like random garbage - strange characters or wrong number of characters compared to what you sent - then you most probably have an incorrect baudrate.

Read-Only
Author
javi pks
Posted
16-May-2008 04:03
Toolset
C51
New! RE: Inicialize struct

OK,
everythings working ok.
The problem was in the global initialitazion.

Thanks

Next Thread | Thread List | Previous Thread Start a Thread | Settings