Jump to content

Recommended Posts

V. 6.35. PIC16F876A


typedef union


unsigned int ad_info[5];



unsigned int current;

unsigned int voltage;

unsigned int battemp;

unsigned int heatsink;

unsigned int max_i;

} ad_data;

} adinform;


adinform actual;





Code is a bit clumsy, but I hade to find out, what was going wrong.

With test values of 0x03 in hi_byte and 0xc0 in lo_byte I get






MAKESHORT(test,lo,hi); // test becomes 960 (0x3c0)


test=actual.ad_info; // test becomes 192 (0x0c0)



What happens to MSB of ad_info?

Link to post
Share on other sites


I came across a minor flaw preparing for other routines in this program.


if(a>B) //(unsigned int types. Both parts of union and structure. Rather complicated)


// empty



It skipped the first two instructions following {} (label placed wrong).


Unable to reproduce at present, as I have removed all unions and structures and is using global addressing instead.

Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...