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.

Return Value of a Function

Status
Not open for further replies.

pavan.emb

Newbie level 5
Newbie level 5
Joined
Oct 21, 2009
Messages
10
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Bengaluru
Activity points
1,364
Hi all,

I am writing an interfacing program for AT28C64B with C8051F120 microcontroller.

But my doubt is " I want to return the STATUS for Write function whether Success or not. I may use an int or char for this. But what I am Thinking is, is it possible to return bit type for a function."


Also i want to know whether I can pass a bit as an argument to a function or not.

Thanks in advance.
 

U think you may be using Silabs IDE....
which compiler ru using?
some compilers support bit data type.... if so u can use it
 

you can create your own enum data type. I usually just use int, but if you insist, you can do something like:

typedef enum _status_T{FAIL = 0, SUCCESS}status_T;

then you can use your function like:

status_T check_something(){

if(yes)
return SUCCESS;

else
return FAIL;
}
 

...you can create your own enum data type...

Despite more complex, is an excelent idea, due other informations can be passed simultaneously.
The program also become more professional.

+++
 

You cannot pass a bit to a function. Nor can you obtain a bit response.
The smallest unit of data you can probably pass will be a byte.
(Unless you are using something unusual)

Your compiler may make it appear to be passing a bit however it
will simply be extracting the bit from the byte for you in the function.

The choice is:
You could allow this to happen if your compiler does this with a "bit" type
or
You can extract the bit from a char/byte or whatever manually yourself
such as pk_volt suggested.

jack
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top