![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Lykos1986
Joined: 26 Nov 2005 Posts: 68
|
Continuous interrupt |
Posted: Sun Dec 07, 2008 11:01 am |
|
|
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();
}
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
dyeatman
Joined: 06 Sep 2003 Posts: 1924 Location: Norman, OK
|
|
Posted: Sun Dec 07, 2008 11:25 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Sun Dec 07, 2008 1:58 pm |
|
|
Basically, the interrupt flag has to be reset in the ISR by reading from the UART, otherwise it must repeat continuously
Why don't you simply try the CCS programming examples? |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|