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 support@ccsinfo.com

int rda and int ext

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



Joined: 05 Jan 2006
Posts: 105

View user's profile Send private message

int rda and int ext
PostPosted: Mon May 21, 2007 12:47 pm     Reply with quote

hi

i want to use two intterupts in pic16f877a, rda and ext but they dont work fine
i notice that ext work good but not rda
help me please
here is my code

Code:


#include <16f877a.h>
#include <string.h>
#fuses xt,NOWDT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#priority rda,ext



static char RX[15] ;
int i;
int1 jj;

#int_rda
void serial_isr()  {
RX[i++]=getch();
jj=1;
}


#int_ext
void ext_isr()  {


   output_high(PIN_D1);
   delay_ms(50);
   output_low(PIN_D1);



}





void main()   {



   enable_interrupts(GLOBAL);
   enable_interrupts(INT_EXT);
   ext_int_edge( H_TO_L );
   enable_interrupts(INT_RDA);
   set_tris_d(0x00);
   jj=0;
while(TRUE)
   {

   if (jj==1)
   {


   output_high(PIN_D2);
   delay_ms(500);
   output_low(PIN_D2);
   jj=0;


   }
   }//while true
}//MAIN




and this is the tx
Code:

#include <16f874.h>
#fuses xt,NOWDT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#include "lcd_kbd1.c"




void main()   {


while(TRUE)
   {


   delay_ms(5000);

   printf("*123456789#");
   }//while
}//MAIN


thank you
Ttelmah
Guest







PostPosted: Mon May 21, 2007 1:22 pm     Reply with quote

Add the keyword 'errors' to your #use RS232 statement.
Get rid of the 50mSec delay in EXT
At 9600bps, a character takes just over 1mSec to arrive. If your program is 'locked' in the EXT interrupt, for more than twice this time, the UART buffer will overflow, and the UART will be in an error state, and never recover.
ERRORS, will allow recovery.
Getting rid of the delay, will stop the problem appearing.
Repeat the mantra :-
_Keep interrupt handlers as fast as possible_.

If you want to pulse a pin for 50mSec, then use a timer, and enable this in the external interrupt routine, then when this interrupts, clear the pin.

Best Wishes
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