Help: c programming for 8051 using labview

Status
Not open for further replies.

Wang Shun Min

Newbie level 1
Joined
Jun 13, 2013
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
11
#define EE_READ 0x03 // EEPROM Read command
char HighByte,LowByte;
int convert_byte (HighByte,LowByte);

HighByte = EE_Read (0X07FE);
LowByte = EE_Read(0x07FE);
address= convert_byte(HighByte,LowByte); // return the converted value of high & low byte to the address
---------------------------------------------------------------------------------------------------------
above is an extract of my code. may i know what does it means to have a declare functions follow by a bracket. (e.g. int convert_byte (HighByte,LowByte); ).

i would also like to know what does this means>>>>>>> "HighByte = EE_Read (0X07FE);"
thanks
 
Last edited:

int convert_byte (HighByte,LowByte); is a function prototype. The function will be defined elsewhere in the program. convert_byte() function takes two arguments which are HighByte and LowByte and they will be 8-bit variables. The function returns 16-bit int data therefore there is int before the function name. The code will combine highbyte and lowbyte into two bytes.

int return;

//...

highbyte = 0xFF;
lowbyte = 0xAA;

return = highbyte; //return will be 0xFF
return = return << 8; // return will be 0xFF00
return = return | lowbyte; //return will be 0xFFAA

return will be returned by the function so you can use something like

value = convert_byte(0xFF, 0xAA); //value is a int variable
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…