Hi,
I am building a controller that works in a bus configuration, here for I am making new subRoutine.
My question is how can I make a function like UART1_Data_Ready(), that I can use the if function directly on the function whitout using an extra char/int.
kind regards
Raphael Baars
ELAB electronic systems
The netherlands
sub Routine HELP
Re: sub Routine HELP
hello ELAB-raph.
You can check the state of RCIF flag bit which sets when a new byte was received. You can develop a polled function to take care of this bit or you can write an interrupt sub routine to achieve the same results.
You can check the state of RCIF flag bit which sets when a new byte was received. You can develop a polled function to take care of this bit or you can write an interrupt sub routine to achieve the same results.
Best Regards
Omar Galicia
Mexico City
Omar Galicia
Mexico City
Re: sub Routine HELP
tnx for te reply,
But I dont no how to make a function like that. :$
what I want is to do :
void function(???) {
?????? how do I do this
}
if (function() == 1) {
...
}
Best Regards
Raphael Baars
ELAB
But I dont no how to make a function like that. :$
what I want is to do :
void function(???) {
?????? how do I do this
}
if (function() == 1) {
...
}
Best Regards
Raphael Baars
ELAB
Re: sub Routine HELP
polled form...
interrupted form...
Code: Select all
.
.
.
if(PIR1.RCIF) //with this conditional you are checking when a byte was received in RCREG register
{ //this code could be in main program or in a function definition.
the code to proccess the data is here
PIR1.RCIF
}
.
.
.
Code: Select all
void interrupt(){
if(PIR1.RCIF){
proccessing the data here
PIR1.RCIF=0;
}
}
Best Regards
Omar Galicia
Mexico City
Omar Galicia
Mexico City
Re: sub Routine HELP
A couple observations.
As was pointed out to me not too long ago, the RCIF bit (in most if not all cases) is not writeable. It is however cleared when you read RCREG.
Also, ELAB-raph asked about
and if you want to pass a value into the function
Hope it helps.
As was pointed out to me not too long ago, the RCIF bit (in most if not all cases) is not writeable. It is however cleared when you read RCREG.
Also, ELAB-raph asked about
in this case, you want a returning value not a void. (pseudo code)what I want is to do :
Code: Select all
void function(???) { ?????? how do I do this } if (function() == 1) { ... }
Code: Select all
unsigned char NerdFunction(void) {
if(cool ==1)
return 0;
else if (lame == 1)
return 1;
}
...
// Now you can use something like
if(!NerdFunction())
KissAGirl();
Code: Select all
#define Cool 0
#define lame 1
unsigned char NerdFunction(unsigned char HairStyle) {
if(HairStyle == Cool)
return 0;
else if (HairStyle == lame)
return 1;
}
...
// Now you can use something like
if(!NerdFunction(MyHair))
KissAGirl();
Re: sub Routine HELP
tnx man,
This was exectly what I was looking for.
I wel try it out soon.
Raphael Baars
ELAB
This was exectly what I was looking for.
I wel try it out soon.
Raphael Baars
ELAB