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

RDA int problem

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



Joined: 27 Jan 2005
Posts: 12

View user's profile Send private message

RDA int problem
PostPosted: Tue Feb 06, 2007 4:27 pm     Reply with quote

I'm sure it's something stupid but I can't seem to figure it out.

I enable the int_rda interrupt. My program works fine until a byte is received in the UART. Then the RDA interrupt runs continuously. I just send one byte, so after it services the interrupt once, it should clear the interrupt and it should not happen again. The disassembly shows that it clears the RXIF bit just before it exits. So why would it get triggered again if the flag is cleared?

I tried this with even an empty ISR routine and it still does it.

16F690


Code:

void main()
{
   
   enable_interrupts(global);

   enable_interrupts(int_rda);

   // main loop
   while(1)
   {      
      putc('-');
   }   // end while

}

#int_rda
void SerRxIsr()
{
   //   SerDataRdy = true;
        //   putc('+');
}



Code:
285:               #int_rda
286:               void SerRxIsr()
287:               {
288:               //   SerDataRdy = true;
289:               //   putc('+');
290:               }
291:               
292:               
   099    128C     BCF 0xc, 0x5
   09A    118A     BCF 0xa, 0x3
   09B    2834     GOTO 0x34


The output is a "-" stream until I tap a key, at which point I get nothing. If I uncomment the putc in the ISR, I get the "-" stream until I press a key, then I get a "+" stream. I never see the "-" again.

Any help is greatly appreciated.

Thanks,
Mike
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Feb 06, 2007 4:45 pm     Reply with quote

Read the 16F690 data sheet, in the Asynchronous USART section.
It says:
Quote:

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.

This means you have to read the character in order to clear the interrupt.
Typically, getc() or fgetc() is used in the #int_rda isr to read the byte.
turbo2ltr



Joined: 27 Jan 2005
Posts: 12

View user's profile Send private message

PostPosted: Tue Feb 06, 2007 5:42 pm     Reply with quote

I thought about that after I posted. I have some other timing critical interrupts and was hoping that I didn't have to read the byte right away, but could just set a flag to read later. Guess I'll at least pull it out of the register in the interrupt.

Thanks.
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