Visti 0 Posted May 1, 2006 Report Share Posted May 1, 2006 V. 6.35. PIC16F876A typedef union { unsigned int ad_info[5]; struct { 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 for(i=0;i<5;i++) { lo=lo_byte; hi=hi_byte; MAKESHORT(test,lo,hi); // test becomes 960 (0x3c0) actual.ad_info=test; test=actual.ad_info; // test becomes 192 (0x0c0) } What happens to MSB of ad_info? Quote Link to post Share on other sites
Dave 0 Posted May 1, 2006 Report Share Posted May 1, 2006 Visti, I have verified this problem, it seems to be a compiler bug. Regards Dave Quote Link to post Share on other sites
Visti 0 Posted May 2, 2006 Author Report Share Posted May 2, 2006 Thanks. I came across a minor flaw preparing for other routines in this program. if(a> //(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. Quote Link to post Share on other sites
Recommended Posts
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.