|
|
View previous topic :: View next topic |
Author |
Message |
krugerrc Guest
|
INT_RDA not working... |
Posted: Thu Dec 20, 2001 12:57 am |
|
|
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... |
Posted: Thu Dec 20, 2001 3:15 am |
|
|
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
|
Re: INT_RDA not working... |
Posted: Thu Dec 20, 2001 12:05 pm |
|
|
:=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... |
Posted: Thu Dec 20, 2001 2:39 pm |
|
|
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 |
|
|
|
|
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
|