CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Interrupt and return data

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Jude
Guest







Interrupt and return data
PostPosted: Sat Feb 07, 2004 9:57 am     Reply with quote

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
PostPosted: Sat Feb 07, 2004 11:30 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Feb 07, 2004 1:11 pm     Reply with quote

Quote:
How work Portb pin0 interrupt (INT) (pic 16f877a)?

The following link contains a demo program for the #INT_EXT interrupt.
http://www.ccsinfo.com/forum/viewtopic.php?t=8504
Jude
Guest







PostPosted: Sat Feb 07, 2004 1:17 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Feb 08, 2004 3:49 pm     Reply with quote

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);
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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