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

PIC16F887 #int_rda problem.

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



Joined: 05 Aug 2008
Posts: 11

View user's profile Send private message

PIC16F887 #int_rda problem.
PostPosted: Sat Aug 09, 2008 9:22 pm     Reply with quote

Hello Friends,

I have written a simple code of using USART receive interrupt system. When the data is received, it jumps to the interrupt function and blinks the led in the function loop with less delay. As soon as it comes out of the interrupt blinking loop, it again enters the same loop detecting interrupt. Its like it keep running in the interrupt loop. I doubt that may be interrupt flag is not cleared when it jumps back to main loop. Please have a look at the code.

Code:
#include "C:\Documents and Settings\Akshay Mathur\Desktop\RS232 test\rs232.h"
int i=0,j;
byte buf[3];

#int_RDA
void  RDA_isr(void)
{
   for(j=0;j<10;j++){output_low(PIN_C0);delay_ms(45);output_high(PIN_C0);delay_ms(45);}
}


void main()
{

   setup_adc_ports(sAN0|sAN1|sAN2|sAN3|sAN4|sAN5|sAN6|sAN7|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);// This device COMP currently not supported by the PICWizard
   enable_interrupts(GLOBAL);
   enable_interrupts(INT_RDA);
//Setup_Oscillator parameter not selected from Intr Oscillotar Config tab

   // TODO: USER CODE!!
   while(TRUE){
   output_low(PIN_C0);
   delay_ms(500);
   output_high(PIN_C0);
   delay_ms(500);
   }
}




Header details:

Code:
#include <16F887.h>
#device adc=10

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz)
#FUSES NOPUT                    //No Power Up Timer
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOCPD                    //No EE protection
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOIESO                   //Internal External Switch Over mode disabled
#FUSES NOFCMEN                  //Fail-safe clock monitor disabled
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOWRT                    //Program memory not write protected
#FUSES BORV40                   //Brownout reset at 4.0V

#use delay(clock=8000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use i2c(Master,Fast,sda=PIN_C4,scl=PIN_C3)
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Aug 09, 2008 10:40 pm     Reply with quote

Quote:

#int_RDA
void RDA_isr(void)
{

for(j=0;j<10;j++)
{
output_low(PIN_C0);
delay_ms(45);
output_high(PIN_C0);
delay_ms(45);
}
}


Its like it keep running in the interrupt loop


The clue is in the 16F8887 data sheet:
Quote:
12.1.2.3 Receive Interrupts
The RCIF interrupt flag bit of the PIR1 register is set
whenever the EUSART receiver is enabled and there is
an unread character in the receive FIFO. The RCIF
interrupt flag bit is read-only, it cannot be set or cleared
by software.
RCIF interrupts are enabled by setting the following
bits:
• RCIE interrupt enable bit of the PIE1 register
• PEIE peripheral interrupt enable bit of the
INTCON register
• GIE global interrupt enable bit of the INTCON
register
The RCIF interrupt flag bit will be set when there is an
unread character in the FIFO, regardless of the state of
interrupt enable bits.

Question: What should you do inside the #int_rda isr to
remove this condition ?

Question #2: If you have massive delays inside your #int_rda isr,
what happens when characters keep coming in, but your isr can't do
anything about them, because it's stuck doing the massive delays ?
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