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

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
krugerrc
Guest







INT_RDA not working...
PostPosted: Thu Dec 20, 2001 12:57 am     Reply with quote

Hi,

I'm writing a program (for the PIC16F877) where I enable the interrupts not at the beginning of, but later in main(). My problem is this: The program works up to the point where I enable the interrupts (I'm only using global and INT_RDA). If I comment out the two lines that enables the interrupts, the rest of the program executes correctly.

What Am I doing wrong??

Here's an example of my program
#int_RDA
RDA_isr() {
RS232=true; //there is some characters waiting...
}

int main(){
...
LCD_INIT();

soft_on();
init_modem();

enter_pin();

if (dbg)
printf(LCD_PUTC,"\f secs count-down");
i=30;
while (i>0){
i--;
if (dbg){
LCD_gotoxy(1,1);
printf(LCD_PUTC,"\%u", i);
}
delay_ms(1000);
}

if (dbg){
printf(LCD_PUTC,"\f Enabling\n Interrupts");
delay_ms(1000);
} //----> program works up to here
enable_interrupts(global);
enable_interrupts(INT_RDA);
if (dbg){
printf(LCD_PUTC,"\f Interrupts\n Enabled");
delay_ms(1000);
}
...

}
___________________________
This message was ported from CCS's old forum
Original Post ID: 1702
Richard Golding
Guest







Re: INT_RDA not working...
PostPosted: Thu Dec 20, 2001 3:15 am     Reply with quote

I think the 'enable_interrupts(global)' statement
should be the last the interrupt list viz:-


enable_interrupts(INT_RDA);
enable_interrupts(GLOBAL);


see example program EX_STWT.C in back of CCS manual
___________________________
This message was ported from CCS's old forum
Original Post ID: 1703
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: INT_RDA not working...
PostPosted: Thu Dec 20, 2001 12:05 pm     Reply with quote

:=Hi,
:=
:=I'm writing a program (for the PIC16F877) where I enable the interrupts not at the beginning of, but later in main(). My problem is this: The program works up to the point where I enable the interrupts (I'm only using global and INT_RDA). If I comment out the two lines that enables the interrupts, the rest of the program executes correctly.
:=
:=What Am I doing wrong??
:=
:=Here's an example of my program
:=#int_RDA
:=RDA_isr() {
:= RS232=true; //there is some characters waiting...
:=}

Do this:

#int_RDA
RDA_isr()
{
char c;

c = getc();

RS232=true;
}

Read the 16F877 data sheet, in the section on the USART
Asynchronous Receiver. It says: "Flag bit RCIF is a
read only bit, which is cleared by hardware. It is cleared
when the RCREG register has been read and is empty."

Ie., you have to clear the receive interrupt condition.
You can do this by reading the byte from the USART.
___________________________
This message was ported from CCS's old forum
Original Post ID: 1707
Mike D
Guest







Re: INT_RDA not working...
PostPosted: Thu Dec 20, 2001 2:39 pm     Reply with quote

Hey, that sorted out one of my problems too.

:=I think the 'enable_interrupts(global)' statement
:=should be the last the interrupt list viz<img src="http://www.ccsinfo.com/pix/forum/disagree.gif" border="0">
:=
:=
:= enable_interrupts(INT_RDA);
:= enable_interrupts(GLOBAL);
:=
:=
:=see example program EX_STWT.C in back of CCS manual
___________________________
This message was ported from CCS's old forum
Original Post ID: 1708
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