Skip to main content
antonius
Associate III
October 10, 2015
Question

Unsigned char is always true ?

  • October 10, 2015
  • 2 replies
  • 869 views
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 topic has been closed for replies.

    2 replies

    markb
    Associate III
    October 10, 2015
    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?

    Tesla DeLorean
    Guru
    October 10, 2015
    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 (See Profile) Up vote any posts that you find helpful, it shows what's working..