![]() | ![]() | ![]() |
| |||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
![]() |
| | Tools |
| | #1 |
|
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();
}
}
Last edited by flit07; 23rd October 2009 at 03:30 PM. | |
| |
| | #2 |
|
bumpz any clues? | |
| |
| | #3 |
|
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) | |
| |
| | #4 |
|
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. | |
| |
| | #5 |
|
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
}
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
}
Last edited by flit07; 24th October 2009 at 01:54 PM. | |
| |
| | #6 |
|
solved.....solved by me again..hahaha TXIF is also set when tx register is not written. so...pic will always get interrupted. | |
| |
|
| 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 |