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

Continuous interrupt

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



Joined: 26 Nov 2005
Posts: 68

View user's profile Send private message

Continuous interrupt
PostPosted: Sun Dec 07, 2008 11:01 am     Reply with quote

Hi! May I have your help? I am trying to set up an interrupt from the serial port using a PIC 16F877. The problem is that the PIC always goes to the interrupt service routineā€¦

What I have to do?


Code:

#include <16f877A.h>
#FUSES XT, NOWDT, NOPUT, NOPROTECT, NOBROWNOUT, NOLVP, NOCPD, NOWRT
#use delay (clock = 4000000)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7,stream=module)

#int_rda
void serial_isr()
{
disable_interrupts(int_rda);
disable_interrupts(global);

output_high(led3);
delay_ms(1000);
output_low(led3);
delay_ms(1000);

enable_interrupts(int_rda);
enable_interrupts(global);
return;
}

void main()
{
........

enable_interrupts(global);
enable_interrupts(int_rda);

   while(1)
   {
   sleep();
   }   
}
dyeatman



Joined: 06 Sep 2003
Posts: 1934
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Dec 07, 2008 11:25 am     Reply with quote

For why it constantly goes to interrupt routine...

http://www.ccsinfo.com/forum/viewtopic.php?t=36800


Also, in the int_rda routine
remove enable and disable interrupt lines, already taken care of by the compiler..
remove the return, already taken care of by the compiler.
Remove the delay, set a flag instead and process in the main loop

Example main loop pseudocode:

Code:

main()
{
   Enable_interrupts(int_rda)
   Enable_interrupts(global)
   set flag false

   While (1)
       {
   
        if flag from interrupt set
            {
               set flag false
               blink LED here
             }

       }
}



Last edited by dyeatman on Sun Dec 07, 2008 2:54 pm; edited 1 time in total
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Sun Dec 07, 2008 1:58 pm     Reply with quote

Basically, the interrupt flag has to be reset in the ISR by reading from the UART, otherwise it must repeat continuously
Code:
c = getc();

Why don't you simply try the CCS programming examples?
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