Unsigned char is always true ?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-09 6:06 PM
Posted on October 10, 2015 at 03:06
Guys,
What should I change for fixing : Warning : comparison of constant 49152 with expression of type ''unsigned char'' is always true ....? the line is : while(Mp3ReadRegister(0x03) != CLOCK_REG) .... unsigned char Mp3ReadRegister( unsigned char addressbyte) #define CLOCK_REG 0xc000 Thanks
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-10 1:50 AM
Posted on October 10, 2015 at 10:50 Mp3ReadRegister() returns an 8 bit value which (when zero-extended) to int (32 bits) will have 24 zero most significant bits so the value can never be equal to 0xc000. Perhaps you need to shift either the function return value or the constant?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-10-10 7:47 AM
Posted on October 10, 2015 at 16:47
So is CLOCK_REG the content of the register? If the registers are 16-bit wide you'd probably want to do the comparison as such.
The compiler just figured out your two numbers can never be the same, so the inequality is always true.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
