![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
maaply Guest
|
Can use External interrupt and Port change interrupt |
Posted: Thu Jan 15, 2009 4:17 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Thu Jan 15, 2009 5:11 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
maaply Guest
|
|
Posted: Thu Jan 15, 2009 7:13 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Jan 15, 2009 8:35 pm |
|
|
Post your current #int_rb routine. |
|
![](templates/subSilver/images/spacer.gif) |
maaply Guest
|
|
Posted: Fri Jan 16, 2009 12:19 am |
|
|
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);
} |
|
|
![](templates/subSilver/images/spacer.gif) |
Guest
|
can i use separately |
Posted: Mon Jan 19, 2009 9:29 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|