🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Variable declaration order

Submitted by ctedie on Wed, 11/23/2011 - 20:03

 

     <p>      Hi,<br/>      I would like to know why my variables are not declared in the order i want.<br/>      I join my Vissim diagram and the C code<br/>      It's in <i>CarteMicroAmbiance.vsm::Micro d'ambiance.Compound.RX/TX.Data</i><br/>      And the declarations are at line 164-167 in CarteMicroAmbiance.c<br/>      </p>

 

Unable to find an attachment - read this blog

Find more posts tagged with

Sort by:
1 - 2 of 21

    Submitted by Anders89 on Tue, 11/29/2011 - 20:38.

    OK, I see the problem. You expected that the variables R1,R2,R3,R4 would be assigned in order as they connected to the compound block edge. The problem is that the R variables have multiple consumers, and ordering is enforced by either vertical position of consumer or edge connection to an enabled/custom rate compound. Normal compounds that do not have custom execution (no enabling or custom rate) have no effect on execution order.
    To fix this, put the 4 SCI reads into a compound that is enabled and trigger with a constant 1 as in the attached update to your diagram.
    Another problem with your diagram was you used an int cast in an expression block that created 32 bit long word out of 4 packet bytes. The int type is only 16 bits on the c2000 so you must use long as your cast.
    See attached update to your diagram.

    Submitted by ctedie on Tue, 11/29/2011 - 20:59.

    Ok, thank you very much!