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 support@ccsinfo.com

Can use External interrupt and Port change interrupt

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







Can use External interrupt and Port change interrupt
PostPosted: Thu Jan 15, 2009 4:17 am     Reply with quote

Hi all,

I am trying to use both interrupt in PORT B. Below is my code, problem is this, always PORT B change interrupt only servicing even the INT pin get the signal. The External interrupt never servicing... How can I make it work ?
Code:
#include "D:\mahesh\Shakira_Development_Modules\CCS\15-01-2009\main.h"

#define RESET   PIN_C2

#int_RB
void  RB_isr(void)
{

output_high(RESET);
delay_cycles(10);
output_low(RESET);

}

#int_EXT
void  EXT_isr(void)
{

output_high(RESET);
delay_cycles(10);
output_low(RESET);

}

#int_TIMER1
void  TIMER1_isr(void)
{
output_high(RESET);
delay_cycles(10);
output_low(RESET);

}



void main()
{

   setup_oscillator(OSC_16MHZ);
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   setup_timer_2(T2_DISABLED,0,1);
   setup_vref(FALSE);
  // enable_interrupts(INT_RB3);
   disable_interrupts(INT_RB0);
   enable_interrupts(INT_EXT);
   ext_int_edge( H_TO_L );      // Sets up EXT
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);

set_tris_c(0x00);
set_tris_b(0x09);
//IOCB=0x08;
 
while(1);

}


Thanks,
maaply
Ttelmah
Guest







PostPosted: Thu Jan 15, 2009 5:11 am     Reply with quote

You will.
Key thing, is that with the 'port changed' interrupt, once triggered, it will keep on triggering 'for ever', till you reset the port latch. This is separate from the interrupt flag (which the compiler will try to reset for you). It is reset, _by the act of reading the port_. Hence when using INT_RB, you _must_ read PortB in the interrupt handler. If you don't, this interrupt will keep triggering.
The same is true of the serial receive interrupt (where you must read the received byte), and the serial transmit interrupt (where you must write a byte to the output latch).
Since you never read the port, the interrupt once fired, will continue for ever...
What chip is this?. On most chips, the INT_RB interrupt is on the high four PortB pins. On the ones where it is available on the low pins, RB0, can be used for _either_ a change interrupt, _or_ a level interrupt, not both. So, 'which chip'.

Best Wishes
maaply
Guest







PostPosted: Thu Jan 15, 2009 7:13 pm     Reply with quote

Thanks Ttelmeh,

This for 16F722 controller. The external interrupt is in PB0 and port change interrupt is in PB3. Even i read the PORT B, RBIF is not reset in simulator.

Thanks,
maaply
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jan 15, 2009 8:35 pm     Reply with quote

Post your current #int_rb routine.
maaply
Guest







PostPosted: Fri Jan 16, 2009 12:19 am     Reply with quote

Code:
#include <16LF723.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPUT                    //No Power Up Timer
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOPROTECT                //Code not protected from reading
#FUSES BROWNOUT                 //Reset when brownout detected
//#FUSES BORV19                #FUSES PLLEN                 #FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOVCAP               
#use delay(clock=8000000)
#define I2C_SCL   PIN_B4
#define I2C_SDA   PIN_B5
#define SPI_CLK   PIN_C3
#define SPI_DI   PIN_C4
#define SPI_DO   PIN_C5
#use rs232(baud=10417,parity=E,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#use i2c(Master,Fast,sda=PIN_B5,scl=PIN_B4)

#int_EXT
void  EXT_isr(void)
{
output_low(RESET);
}

#int_RB
void  RB_isr(void)
{
char a;
a=input_b();
output_high(RESET);
}


#int_TIMER1
void  TIMER1_isr(void)
{
output_high(RESET);
delay_cycles(10);
output_low(RESET);

}



void main()
{

   setup_oscillator(OSC_16MHZ);
   setup_adc_ports(NO_ANALOGS|VSS_VDD);
   setup_adc(ADC_OFF);
   setup_spi(SPI_MASTER|SPI_L_TO_H|SPI_CLK_DIV_4);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_INTERNAL|T1_DIV_BY_8);
   setup_timer_2(T2_DISABLED,0,1);
   setup_vref(FALSE);
   enable_interrupts(INT_EXT);
   ext_int_edge( H_TO_L );      // Sets up EXT
   enable_interrupts(INT_RB3);
   enable_interrupts(INT_TIMER1);
   enable_interrupts(GLOBAL);

set_tris_c(0x00);

   // TODO: USER CODE!!
while(1);

}
Guest








can i use separately
PostPosted: Mon Jan 19, 2009 9:29 pm     Reply with quote

PCM programmer wrote:
Post your current #int_rb routine.



Thanks PP,

Can you please help me to come out from this problem?
Is it possible to use this 2 interrupt ( Port Change and External) separately?
Because, even i give the pulse to int pin the #int_RB isr routine is executing.
The IOCB register is loaded value 0x08.

Thanks
maaply
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