|
|
View previous topic :: View next topic |
Author |
Message |
Jude Guest
|
Interrupt and return data |
Posted: Sat Feb 07, 2004 9:57 am |
|
|
Sorry, i speak english very little.
How work PortB pin0 interrupt (INT) (pic 16f877a)?
I write code in CCS pic c.
This is ok -> temp1=program(); Program return(data);
Can i return two data ( "return(data1, data2)" ).
Thanks. |
|
|
ttelmah Guest
|
Re: Interrup and return data |
Posted: Sat Feb 07, 2004 11:30 am |
|
|
Jude wrote: | Sorry, i speak englis very litte.
How work bortb pin0 interrup (INT) (pic 16f877a)?
I write code in css pic c.
This is ok -> temp1=program(); Program return(data);
Can i return two data ( "return(data1, data2)" ).
Thanks. |
The interrupt functions, do not return data.
If you need to return data from an interrupt, use a global variable. In any other function, only one data return is allowed, but there is nothing to stop this being an array, or a structure.
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Jude Guest
|
|
Posted: Sat Feb 07, 2004 1:17 pm |
|
|
Ou yeah.
I write two questions (but very bad english).
1. How work INT (portb, pin 0) interrup (CSS C).
2. How i can retur two variable. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 08, 2004 3:49 pm |
|
|
Quote: | 2. How i can return two variables. |
I guess you want a demo program that shows how
to return more than one variable in a structure
(as suggested by R.J. in his reply).
Here is a demo that shows how to return 3 variables
in a structure.
Code: | #include <16F877.h>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 4000000)
#use rs232(baud = 9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
// Create a structure data type that will hold
// the three return values.
typedef struct
{
char a;
char b;
char c;
}t_ret3;
// FUNCTION PROTOTYPES
t_ret3 my_func(void);
//========================================
main()
{
t_ret3 t_result;
t_result = my_func();
printf("Return values are: %x, %x, %x \n\r", t_result.a, t_result.b, t_result.c);
while(1);
}
//==========================================
// Create a small function, as a test, that will just
// set three values and return them as a structure.
t_ret3 my_func(void)
{
t_ret3 retvals;
retvals.a = 0x55;
retvals.b = 0xAA;
retvals.c = 0x11;
return(retvals);
} |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|