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 int_rda not working

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



Joined: 31 Aug 2009
Posts: 6

View user's profile Send private message

interrupt int_rda not working
PostPosted: Sat Mar 23, 2013 2:23 pm     Reply with quote

I create a simply program to test rda interrupt, but for some reason the interrupt is not working. When send a TX data expect a message back “Interrupt in execution”, but no message is send back. Look at the program below.
Code:

#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#int_rda
void serial_isr(){
printf("interrupt in execution");
getc();
   }

Main{
Enable_interrupt (Global);
Enable_interrupt (int_rda);}
When(true){
}
jayanthd



Joined: 06 Dec 2012
Posts: 47
Location: Banned - pirate

View user's profile Send private message

Re: interrupt int_rda not working
PostPosted: Sat Mar 23, 2013 3:15 pm     Reply with quote

How are you sending data to UART? Only if you send some data like say 'A' serial interrupt occurs and printf is executed.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sat Mar 23, 2013 3:23 pm     Reply with quote

Several things:-

1) Can you get an LED flasher to work?
2) Add errors to your #use RS232.
3) Where does your code go after the enable rda interrrupt?
4) Does your code ever reach the when statement?
5) Is "when" a valid 'C' word?
6) Have you carefully examined your {} brackets?
7) Does your code compile without errors?
8) Printing inside an ISR is a VERY bad idea.
9) Is this real or simulation?
10) .......................

Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Mar 23, 2013 4:11 pm     Reply with quote

Try a more simple #int_rda test program like this one:
http://www.ccsinfo.com/forum/viewtopic.php?t=37380&start=3
Notice it has the ERRORS parameter in #use rs232() and it only sends
one character in #int_rda. It quickly gets out of the interrupt routine.
Ttelmah



Joined: 11 Mar 2010
Posts: 19498

View user's profile Send private message

PostPosted: Sun Mar 24, 2013 1:34 am     Reply with quote

Keyword for a loop is 'while', not 'when'....
So code as posted will not compile.
Mike Walne



Joined: 19 Feb 2004
Posts: 1785
Location: Boston Spa UK

View user's profile Send private message

PostPosted: Sun Mar 24, 2013 4:25 am     Reply with quote

There several reasons why your code won't compile.

My advice on {} brackets (for what it's worth).
Always locate each closing } directly below its opening { with clear space between.
That way you can more easily see your code structure.

Your code now becomes:-
Code:
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,NOBROWNOUT
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#int_rda
void serial_isr()
{
   printf("interrupt in execution");
   getc();
}

Main
{
   Enable_interrupt (Global);
   Enable_interrupt (int_rda);
}
When(true)
{
}

It should now be obvious what's wrong with the structure.
I've not altered the sense of your code.
The only editing I've done is to manipulate white space and linefeeds.
It still won't either compile or work for the reasons that were there before.
The compiler complains about things it can't handle, and effectively tells you where to look for errors.

Mike
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