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
lam
Guest







Interrupts?
PostPosted: Thu Feb 04, 2010 4:03 pm     Reply with quote

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







PostPosted: Thu Feb 04, 2010 4:05 pm     Reply with quote

Ive got

IDE, PCB, PCM, PCH 4.074
and PCD 4.068
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Feb 04, 2010 4:07 pm     Reply with quote

RB0 interrupts use #int_ext, not #int_rb. Also fix the enable_interrupts()
line in the same way.
Guest








PostPosted: Thu Feb 04, 2010 4:14 pm     Reply with quote

so what for are RB interrupts?
for other RB pins ? Pin_b1, pin_b2?
lam
Guest







PostPosted: Thu Feb 04, 2010 4:19 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Feb 04, 2010 4:27 pm     Reply with quote

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







PostPosted: Thu Feb 04, 2010 4:32 pm     Reply with quote

THX PCM : )
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