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

Interrupts

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Michaelc



Joined: 18 Nov 2003
Posts: 14
Location: Ireland

View user's profile Send private message

Interrupts
PostPosted: Fri Apr 02, 2004 8:09 am     Reply with quote

Hey
Can anyone tell my an interupt occurs when the pic is starting up?
The code is below:

#include<inttest.h>
#include<des_lcd.c>
#include<dipkey.c>

static int j;
/////////////////////////////////////////////////////////////////////////
////////Interrupt Service routine for change on port b////////////
/////////////////////////////////////////////////////////////////////////
#int_rb
rb_isr ( )
{

static int ran = 0;
static int portstatus;

portstatus = port_b;
j++;

printf("isr");
delay_ms(3000);
}



void main()
{
///////////////////////////////////////////////////////////////////
//////////////////////Declare Local Variables //////////////////////
static byte status;
int low_detected = 0;
//////////////////////////////////////////////////////////////////////
//////////////////////Disable interrupts//////////////////////////////
//////////////////////////////////////////////////////////////////////
disable_interrupts(GLOBAL);
disable_interrupts(INT_RB);
//////////////////////////////////////////////////////////////////////
//////////////////////Initialise lcd//////////////////////////////////
lcd_init();
set_tris_b(0xf0);
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_CLOCK_DIV_2);
setup_spi(FALSE);
setup_psp(PSP_DISABLED);
setup_ccp1(CCP_OFF);
setup_ccp2(CCP_OFF);
//////////////////////////////////////////////////////////////////////
///////////////////////Setup Watchdog Counters////////////////////////
///////////////////////Reset = every 2.3secs /////////////////////////
setup_counters(RTCC_INTERNAL,WDT_2304MS);

///////////////////////////////////////////////////////////////////////
///////////////////////////Setup Timers////////////////////////////////
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
///////////////////////////////////////////////////////////////////////
//////////Setup interrupt on Port B change ////////////////////////////
///////////////////////////////////////////////////////////////////////
status = port_b; //read the status before enabling the interrupt
enable_interrupts(INT_RB);

///////////////////////////////////////////////////////////////////////
/////////////////////////Enable interrupts ////////////////////////////
///////////////////////////////////////////////////////////////////////
enable_interrupts(global);


printf("reset");
while(1)
{
i++;
restart_wdt();
}
//restart_wdt();
}

The interrupt ocurs on change on port b, but as can be seen i have the interrupts disabled. The program never reaches the printf("reset"); line!
Why is this?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 12:02 pm     Reply with quote

Where is your declaration for port_b ?

It should look like this, if you are using a 16F series PIC:

#byte port_b = 6
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Fri Apr 02, 2004 12:38 pm     Reply with quote

It's just a guess but I would try clearing the interupt flag between these two lines.

Code:
status = port_b; //read the status before enabling the interrupt
enable_interrupts(INT_RB);
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