Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC18F2550 constatly firing interrupt

Status
Not open for further replies.

poorchava

Advanced Member level 1
Joined
May 21, 2009
Messages
429
Helped
71
Reputation
142
Reaction score
71
Trophy points
1,318
Location
Wrocław, Poland
Activity points
4,780
Ok, now's the time to ask others. I'm pulling my hair off trying to figure out what's going on.

I'm trying to get pic18f2550 to ionterrupt on receiving character via uart. (simple setup using max232). Here's my code

Code:
#include "main.h"
#include "delays.h"
#include "usart.h"

#pragma config FOSC=HSPLL_HS
#pragma config PLLDIV=4
#pragma config CPUDIV=OSC1_PLL2
#pragma config PBADEN=ON


	unsigned char i=0;
	unsigned long j=0;
	unsigned int offtime=60000;
	char dummy=0;
	
#pragma code high_interrupt = 0x08
void high_interrupt (void)
{	
	INTCONbits.GIE=0;INTCONbits.PEIE=0;
	if(PIR1bits.RCIF==1)
	{
		dummy=RCSTA;
		dummy=RCREG;
		PIR1bits.RCIF=0;			
	}	
	INTCONbits.GIE=1;
	INTCONbits.PEIE=1;
}	
#pragma code
void main(void)
{
	TRISCbits.TRISC7=1;
	OpenUSART(USART_TX_INT_OFF|USART_RX_INT_ON|USART_ASYNCH_MODE|USART_EIGHT_BIT|USART_SINGLE_RX|USART_BRGH_HIGH|USART_ADDEN_OFF,311);

	INTCONbits.PEIE=1;
	PIR1bits.RCIF=0;
	PIE1bits.RCIE=1;
	INTCONbits.GIE=1;
        while(1);

Now the problem is that pic is either resetting to the line
Code:
_asm goto _startup _endasm
in startup file all the time
or the interrupt if firing all the time without any signal being sent through uart (confirmed with scope - constant high logic level). When i'm reading PIR1 register, the RCIF bit never goes low even when I clear it in interrupt routine
Code:
		PIR1bits.RCIF=0;

Pls give me some ideas because I'm about to throw this crap outa window -,-. I've always bee doing interrupts that way and can't understand why it isn't working this time and strange stuff happens
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top