Sign in to follow this  
Followers 0
HelGaa

Union

3 posts in this topic

Hello!

I am trying to get hold of the bits in a word, i have read that union is the way to go.

My problem is that i cant figure out how union works. I have made a union between a word (16bit) and an array(0...15). The way I understood this was that the word now automaticly updates the array so that when the least significant bit in the word should update array[00] and so on.

This is not happening. When I monitor the variables I can see the word change, but nothing happens with the array.

Have I misunderstood the consept and what should I do to get hold of the bits?

Share this post


Link to post
Share on other sites

Did you do everything with respect to Unions as I suggested in this post:

Here is my union definition:

Bz4mK8kDuq+PAAAAAElFTkSuQmCC

Here is my variable definition:

1W5ZRiGYRim67DGzDAMwzBBBAtmhmEYhgkiWDAzD

Here is my simulated program (all that I did in simulation was to set on Bit00 of the array):

wM19YpNMzNtZAAAAABJRU5ErkJggg==

Note that the value of UnionTesting.WordVal = 0001 Hex.  As expected, the least significant bit turned on when I set bit 0 on.

 

Share this post


Link to post
Share on other sites

Thank you for your help!

I had the global variables all wrong!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0