Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] "unsigned char" is always true ....?

Status
Not open for further replies.

bianchi77

Advanced Member level 4
Joined
Jun 11, 2009
Messages
1,313
Helped
21
Reputation
44
Reaction score
20
Trophy points
1,318
Location
California
Activity points
9,442
Guys,

What should I change for fixing :
Warning : comparison of constant 49152 with expression of type "unsigned char" is always true ....?

the line is :
Code:
while(Mp3ReadRegister(0x03) != CLOCK_REG)

....

unsigned char Mp3ReadRegister( unsigned char addressbyte)

#define CLOCK_REG       0xc000

Thanks
 

What should I change for fixing :
Warning : comparison of constant 49152 with expression of type "unsigned char" is always true ....?

The simple fact is the following conditional is always true:

Code:
Mp3ReadRegister(0x03) != CLOCK_REG

How can a type of unsigned char with a maximum value of 0xFF, ever equal 0xC000?

It obviously cannot.

The only way the above conditional makes sense is if your defined value of CLOCK_REG is within the range of an unsigned char, 0x00 to 0xFF.


BigDog
 

What variable type should I use then ? what's your suggestion ? thanks
The simple fact is the following conditional is always true:

Code:
Mp3ReadRegister(0x03) != CLOCK_REG

How can a type of unsigned char with a maximum value of 0xFF, ever equal 0xC000?

It obviously cannot.

The only way the above conditional makes sense is if your defined value of CLOCK_REG is within the range of an unsigned char, 0x00 to 0xFF.


BigDog
 

How could we know?

Either the function prototype or the constant definition is erroneous.
 

:

Code:
unsigned long Mp3ReadRegister( unsigned long addressbyte)
 

O.K., but what's inside the function body? How's the return value derived? Is it a 16-bit register read result? With an ANSI C compiler, a 16-bit value would have the type unsigned, not unsigned long.

I don't understand why you have changed the address type, too.
 

O.K., but what's inside the function body? How's the return value derived? Is it a 16-bit register read result? With an ANSI C compiler, a 16-bit value would have the type unsigned, not unsigned long.

I don't understand why you have changed the address type, too.

the function :
Code:
unsigned long Mp3ReadRegister( unsigned long addressbyte)
{
	

	int resultvalue = 0;
	Mp3DeselectData();
	Mp3SelectControl();				//XCS = 0
	uint8_t data7[2] = { VS_READ_COMMAND, addressbyte };
	
	HAL_SPI_Transmit(&hspi1,data7,2,1000);
	uint8_t data8[1] = {0x00};
  data8[0] = 0;
	
	
	
	HAL_SPI_Receive(&hspi1,data8,1,1000);
	resultvalue = data8[0];
	resultvalue <<= 8;
	HAL_SPI_Receive(&hspi1,data8,1,1000);
	resultvalue += data8[0];
   	
	Mp3DeselectControl();              
	return resultvalue;           	//??16??????

}

Please correct me if I'm wrong ? thanks
 

probably
Code:
unsigned int Mp3ReadRegister( unsigned char addressbyte)
will be enough
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top