View previous topic :: View next topic |
Author |
Message |
lam Guest
|
Interrupts? |
Posted: Thu Feb 04, 2010 4:03 pm |
|
|
I've got problem with interrupts.
I make a 10k pullup on RB0 (INT0) and I'm trying to call interrupt function when the pin is grounded.
My function is :
Code: |
#INT_RB
void IPF(void)
{
lcd_gotoxy(2,1);
lcd_putc("INTERRUPT");
delay_ms(500);
lcd_clear();
}
void main(void)
{
setup_adc_ports(AN0 |VREF_VREF);
setup_adc(ADC_CLOCK_DIV_8);
set_adc_channel(0);
setup_psp(PSP_DISABLED);
setup_wdt(WDT_OFF);
setup_timer_0(RTCC_INTERNAL);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_timer_3(T3_DISABLED|T3_DIV_BY_1);
setup_comparator(NC_NC_NC_NC);
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_XMIT_L_TO_H | SPI_CLK_DIV_4);
delay_ms(10);
EXT_INT_EDGE(H_TO_L);
enable_interrupts(INT_RB);
enable_interrupts(GLOBAL);
lcd_init();
lcd_clear();
for(;;){
lcd_gotoxy(1,1);
lcd_putc("Standby :"); delay_ms(1000);
}
}
|
Nothing happens ... the CPU never enters the interrupt function. |
|
|
lam Guest
|
|
Posted: Thu Feb 04, 2010 4:05 pm |
|
|
Ive got
IDE, PCB, PCM, PCH 4.074
and PCD 4.068 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 04, 2010 4:07 pm |
|
|
RB0 interrupts use #int_ext, not #int_rb. Also fix the enable_interrupts()
line in the same way. |
|
|
Guest
|
|
Posted: Thu Feb 04, 2010 4:14 pm |
|
|
so what for are RB interrupts?
for other RB pins ? Pin_b1, pin_b2? |
|
|
lam Guest
|
|
Posted: Thu Feb 04, 2010 4:19 pm |
|
|
Forgive me for flooding. but I've got one more question.
How the 'interrupt' works?
If CPU are processing some code when interrupt occurs it will be 'stopped' at some point and when interrupt function ends CPU will continue to execute 'normal' code from the point when it stops to enter interrupt? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Feb 04, 2010 4:27 pm |
|
|
Quote: |
CPU are processing some code when interrupt occurs it will be 'stopped' at some point and when interrupt function ends CPU will continue to execute 'normal' code from the point when it stops to enter interrupt? |
Yes, that's right.
Quote: | so what for are RB interrupts? |
Interrupt-on-change. Normally for pins RB4-RB7.
But it can depend upon your PIC. Always post your PIC. |
|
|
lam Guest
|
|
Posted: Thu Feb 04, 2010 4:32 pm |
|
|
THX PCM : ) |
|
|
|