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

Global interrupt in pic 16f877

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
el-3aba6i



Joined: 20 Sep 2018
Posts: 4

View user's profile Send private message

Global interrupt in pic 16f877
PostPosted: Thu Sep 20, 2018 1:04 am     Reply with quote

Can i use multiple interrupts in pic16f877a ?
I have this code:
Code:

#int_global
void global_interrupt () {
**code**
}

void main () {
**code**
enable_interrupts(global);
enable_interrupts(int_rda);
enable_interrupts(int_ext);
ext_int_edge(h_to_l);
}

Can this work???? and thanks for your help.
Ttelmah



Joined: 11 Mar 2010
Posts: 19516

View user's profile Send private message

PostPosted: Thu Sep 20, 2018 1:36 am     Reply with quote

I think you are seriously misunderstanding interrupts.

Yes you can have multiple interrupts, if you get rid of the int_global handler.
Have a handler for #INT_EXT, and a handler for #INT_RDA. Each will be called when the corresponding interrupt triggers (remember that INT_RDA must read the serial port of this interrupt will never clear).

However if you have a #INT_GLOBAL handler, this replaces _all other interrupts_. It is called when any interrupt triggers. It must then contain your own code to save all variables used, and if multiple interrupts are used, it must poll all of them.

Get rid of the int_global handler, and then your other interrupts can behave normally. The INT_GLOBAL handler is only used if you are writing the entire interrupt handling system yourself.

You still need to enable #INT_GLOBAL. This is not in itself an 'interrupt', it is a 'master flag' allowing all interrupts to be enabled/disabled at once. If you use it as an 'interrupt', you are saying that you want to take over complete control of the interrupt system....
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