Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 23rd October 2009, 03:29 PM   #1
Default Interrupt: Looping in ISR

Hi,

I'm using PIC16f877, writing a simple ISR, but it keeps on looping within ISR, if i set PEIE, though beforehand i've reset all interrupts flags.

Could anyone shed some light?

Code:
	INTE = 0;
	init_uart();  // set RCIE and TXIE
	reset_IF();  // reset all interrupt flags
	GIE = 1;
	PEIE = 1;     // keeps on looping if i set PEIE  <-- problem here
	__enable_interrupt();
	while(1)
	{       
		while( ReceivedCount < 50)  // guard condition for every ISR done
		{
			do_foreground_process();  
		}
        }
thanks!

Last edited by flit07; 23rd October 2009 at 03:30 PM.
flit07 is offline  
Old 24th October 2009, 12:15 PM   #2
Default

bumpz
any clues?
flit07 is offline  
Old 24th October 2009, 12:26 PM   #3
Default

Lets see the ISR.
__________________
Please post questions to the forums. PM's are for personal communication.

BCHS/3v0's Tutorials
Junebug USB PIC programmer kit., USB Bit Whacker,
The 15 Minute Printed Circuit Board! (+drill time)
3v0 is offline  
Old 24th October 2009, 12:27 PM   #4
Default

Where is your interrupt code? Can you show your init_uart code? Is your UART input pins pulled up? Are you clearing the interrupt flag inside the interrupt?
__________________
A rectangular bear is just a polar bear after a coordinate transform. -- I dunno who.
A recent study shows that research causes cancer in rats. -- I dunno who said that one either.
Noggin is offline  
Old 24th October 2009, 01:50 PM   #5
Default

Ok.,..
The ISR as follow

Code:
__interrupt void tutor_interrupt(void) 
{ 
		RB7 = 1;    // LED indicator, PORTB change Disabled
		ReceivedCount  += 1; // check condition to complete program
		c[0] = RCREG;   // read received Byte, Never mind on the data content, I just want to clear RCIF by reading RCREG
		flag = 1;  // Indicator for do_foreground_process
}
init_uart() as follow

Code:
void init_cntr(void)
{
  TRISC = TRISC | 0x80; //  set RC7 (RX) as input
  TRISC = TRISC & 0xBF; //  set RC6 (TX) as output
  BRGH=1;		//  high speed
  SPBRG=0x81;  	        //  baud rate 9600Bdps1
  SYNC=0;		//  synchronous mode disabled 
  SPEN=1;		//  Enable pin for transmission
  TXIE=1;		//  int  desired
  TXEN=1;		//  TX Enable
  TX9=0;                //  8 Bit transmission
  TRMT=1;               
  
  // Reception
  RCIE=1;               //  int desired
  RCIF=0;           // clear RC flag
  RX9=0;                //  8 bit reception
  TRMT=1;               //  TSR empty
  CREN=1;               //  Enables continuous receive
  TX9D=0;		//  8 bit transmission
  RX9D=0;               //  8 bit receive
}
And that's all the code. simple module to be integrated into a big one. I did clear off RC flag inside ISR. But it keeps looping inside ISR if i set PEIE. Why?

Last edited by flit07; 24th October 2009 at 01:54 PM.
flit07 is offline  
Old 25th October 2009, 02:25 PM   #6
Default

solved.....solved by me again..hahaha

TXIF is also set when tx register is not written.
so...pic will always get interrupted.
flit07 is offline  
Reply

Tags
interrupt, isr, looping

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
delay for ISR to activated faysal_002299 Micro Controllers 5 26th December 2008 03:55 AM
How to switch between programs using ISR sohagiut Micro Controllers 18 22nd February 2008 07:44 PM
Calling Subroutines inside the ISR Suraj143 Micro Controllers 6 12th December 2007 11:22 PM
looping problems using picbasicpro pouchito Micro Controllers 6 8th June 2007 09:07 AM
IR ISR problem timothyjackson Micro Controllers 1 17th March 2005 11:09 AM



All times are GMT. The time now is 06:35 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker