cancel
Showing results for 
Search instead for 
Did you mean: 

How to compare a result of a function ?

antonius
Senior
Posted on October 11, 2015 at 12:39

Guys,

How can compare the result of the furnction output ?

I have on main.c :

Code:

result = VS1053_Init(); if (result == 0) { HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6 , 1 ); HAL_Delay(100); HAL_GPIO_WritePin(GPIOE, GPIO_PIN_6 , 0 ); }

and :

vs.c :

Code:

unsigned char VS1053B_Init() { . . . return 0; }

Thanks
1 REPLY 1
Posted on October 11, 2015 at 18:47

Presumably related to [DEAD LINK /public/STe2ecommunities/mcu/Lists/STM32Java/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/STM32Java/Unsigned%20char%20is%20always%20true&FolderCTID=0x01200200770978C69A1141439FE559EB459D758000F9A0E3A95BA69146A17C2E80209ADC21&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/STM32Java/AllItems.aspx&currentviews=19]this thread. Try to keep materially connected stuff in one thread, please.

Yes, the code here looks reasonable enough.

Your problem is more likely when trying to compare things when aren't directly comparable, or of the same ranges.

XX == YYYY ?

If the number you want is 16-bit wide, then holding it in an 8-bit variable isn't going to work. The most significant 8-bits of information will get wiped away.

Maybe you want to go back and review the chapter on numeric representation, and how numbers would be held in 8, 16, or 32-bit variables/registers

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..